Monday, March 12, 2012

Java Garbage Collection and the Java HotSpot VM


The Garbage Collection model in today’s JVM achieve maximum efficiency incorporating the Generational Garbage Collection Model. This implementation was first introduced in the Java HotSpot VM for Solaris and is widely.


The implementation essentially eliminates the overhead involved in the JVMs attempt to scan through all the objects in the Java heap space, during every single GC attempt. The entire heap space is broken into two Generations, providing distinct and separate memory pools for Long Lived Objects (typically Singletons in a Web container) and Young or New Objects. The newly created Young objects are pushed into the new generation (also called as Eden). If they protrude a longer life then subsequently these are pushed into the old generation.


The GC attempts are classified as either Minor Collections or Major Collections. In the Minor collection the GC passes through the new generation and in the Major collection the GC passes through the entire heap space, including the old generation pool. As evident, the Minor collections are more frequent, as compared to the Major collections, which happen only when the old generation pool runs out of space. During the Major GC the live threads are suspended and may terminate abnormally.

No comments:

Post a Comment