Saturday, 14 June 2014
Java Garbage Collection Mechanism
Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory.
The purpose of garbage collection
is to identify and remove objects that are no longer needed by a program. A
Java object is subject to garbage collection when it becomes unreachable to the
program in which it is used. Every class inherits finalize() method from
java.lang.Object, the finalize() method is called by garbage collector when it
determines no more references to the object exists. Calling System.gc() and
Runtime.gc(), JVM tries to recycle the unused objects
No guarantee that Garbage collection will start immediately upon request of System.gc().
No guarantee that Garbage collection will start immediately upon request of System.gc().
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment