English French German Spain Italian Dutch Russian Portuguese Japanese Korean Arabic Chinese Simplified

Wednesday, October 8, 2008

Garbage collection

Garbage collection is a process of automatic memory management. GC is a part of JVM, which is used to recycle the memory to the object. The most important thing is that GC cannot be forced explicitly. It is performed by JVM when it is short of memory. The two ways System.gc() or new Runtime.gc() does not forces the GC, it can only gives a suggestion to JVM. GC generally uses a algorithm, which gives a fair balance for memory recovery. An object is eligible foe GC only when it has no object refers to it, and reference is made null. Finally () method is called only once by GC before deleting unreachable object. You can make object ineligible for garbage collection in the finalize() method. GC is one of the powerful tools in java, which makes it more reliable.

No comments: