Sunday 22 February 2015

What is Garbage Collection and Does Java have destructors?

Garbage collection is the process of looking at heap memory, identifying which objects are in use and which are not, and deleting the unused objects.

Step 1: Marking
Step 2: Normal Deletion
Step 2a: Deletion with Compacting

Why Generational Garbage Collection?

The information learned from the object allocation behavior can be used to enhance the performance of the JVM. Therefore, the heap is broken up into smaller parts or generations. The heap parts are: Young Generation, Old or Tenured Generation, and Permanent Generation
 General Garbage collection process


Java does not have destructors; but it has finalizers that does a similar job. 
the syntax is
 
public void finalize(){ 
}

No comments:

Post a Comment