>>> The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused.
>>> An unreachable object is subjected to gc. Unreachable objects are those which can not be referenced.
>>> Garbage collection is also called automatic memory management as JVM automatically removes the unused variables/objects (value is null) from the memory.
>>> 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.
>>> In Java, it is good idea to explicitly assign null into a variable when no more in use.
>>> In Java on calling System.gc() and Runtime.gc(), JVM tries to recycle the unused objects, but there is no guarantee when all the objects will garbage collected.
>>> Garbage collection is an automatic process and can't be forced.
>>> gc thread is a dameon thread.
No comments:
Post a Comment