Posts

Showing posts with the label Garbage collection in java

Garbage Collection in java

  Garbage Collection in java Garbage means unreferenced objects. Garbage collector is responsible for collect unused objects. Garbage Collection is process of reclaiming the runtime unused memory automatically. In other words, it is a way to destroy the unused objects. The process of removing unused objects from heap memory is known as  Gar bage collection . We know that objects are dynamically allocated by using the new operator and objects are destroyed and their memory released for later reallocation. In some languages, such as C++, dynamically allocated objects must be manually released by use of a delete operator. In Java, garbage collection done  automatically for you. Steps required to perform garbage collection : 1.The unreferenced objects are identified and marked as ready for garbage collection. 2.The marked objects are deleted by the garbage collector. 3.optionally,memory can be compacted after garbage collector deletes objects,so remaining objects ...