Win a copy of Pro Spring MVC with WebFlux: Web Development in Spring Framework 5 and Spring Boot 2 this week in the Spring forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Bear Bibeault
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh

how to use those functions

 
Ranch Hand
Posts: 68
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
System.runFinalization();
System.runFinalizersOnExit( true );
System.gc()
who can explain those functions in detail, and where and how to use them in practice.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Niu,
From my understanding of this here's how this works.
System.gc() is an explicit call to the garbage collector. However, this is only a suggestion to run, as when it runs and when unreferenced objects are run is up to the VM.
System.runFinalization() - A method may implement the finalize() method inherited from the Object class to cleanup after itself (memory, other resources etc.). The finalize() method is called by the garbage collector before it
disposes of the object. The System.runFinalization() method is an explicit call that executes the finalize() methods of any objects
awaiting garbage collection. There is no guarantee which order finalize() methods are called on objects awaiting gc.
System.runFinalizersOnExit( true )-
(from 1.4.1 spec)Deprecated. This method is inherently unsafe. It may result in finalizers being called on live objects while other threads are concurrently manipulating those objects, resulting in erratic behavior or deadlock.
essentially what this does is run the finalize() method of objects which have not been garbage collected when the rruntime exits.
Hope this helps,
Kem

Originally posted by Niu Xiuyuan:
System.runFinalization();
System.runFinalizersOnExit( true );
System.gc()
who can explain those functions in detail, and where and how to use them in practice.

 
I'm all tasted up for a BLT! This tiny ad wants a monte cristo!
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic