Thursday, April 27, 2006

Young Heap [Info Blog]

The Java HopSpot VM uses a modified form of generational algorithms for garbage collection. Generational algorithms are based on two assumptions:
  1. Most program objects exist for a short period of time
  2. There are a few objects that exist for very long periods of time
Generational algorithms divide the heap into subsections, each of which represents a generation of objects. The young heap (or the subsection containing the youngest generation of objects) gets garbage collected most frequently. Objects from the young heap that survive a few rounds of garbage collection are promoted to an older subsection.

This algorithm is efficient because objects with the least probability for eing garbage collected are tested for their elligibility the least number of times. Also since some garbage collection algorithms involve moving objects (regardless of whether they will be garbage collected), this approach is faster because it moves fewer objects.

No comments: