July 6, 2010

The Java heap

The young generation consists of eden plus two survivor spaces. Objects are initially allocated in eden. One survivor space is empty at any time, and serves as a destination of the next, copying collection of any live objects in eden and the other survivor space. Objects are copied between survivor spaces in this way until they are old enough to be tenured, or copied to the tenured generation.

-Tuning Garbage Collection with the 5.0 Java[tm] Virtual Machine by Sun

The Java HotSpot VM defines two generations: the young generation (sometimes called the "nursery") and the old generation. The young generation consists of an "Eden space" and two "survivor spaces." The VM initially assigns all objects to the Eden space, and most objects die there. When it performs a minor GC, the VM moves any remaining objects from the Eden space to one of the survivor spaces. The VM moves objects that live long enough in the survivor spaces to the "tenured" space in the old generation. When the tenured generation fills up, there is a full GC that is often much slower because it involves all live objects. The permanent generation holds all the reflective data of the virtual machine itself, such as class and method objects.

-Using JConsole by Sun

See figure at either link above (both use the same figure).

Mark-and-Sweep Garbage Collection, used in Tenured Generation GC
Stop-and-Copy Garbage Collection, used in Young Generation GC
The Copy Algorithm, used in the Stop-and-Copy method of GC

No comments:

Post a Comment