• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.

 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic