When JVM starts up, a heap area is created, which is called a runtime data area. This is the place where all the objects are stored. It is required to manage this area efficiently by clearing the objects that are no longer in use since this area is limited. The procedure of removing unused objects from heap memory is called Garbage collection. It is a part of memory management in Java. The garbage collection is automatic in java. Garbage Collection is the process of taking back the unused memory automatically at the runtime that is how the unused objects are getting destroyed.
Java has these automatic functions unlike C and C++ where we use free() and delete() functions respectively to free up the unused spaces during the runtime.
Due to Garbage Collector, java is more memory efficient which removes unreferenced objects from the heap memory.
JVM has a dedicated Garbage Collector for the automatic collection of the unused heap memory so that we do not have to make extra efforts.
Knowledge2life 1
Knowledge2life 1
|