JavaFAQ Home » General Java
Question: What is young generation in GC(Garbage Collector)?
Answer: In the J2SE platform version 1.4.1 two new garbage collectors
were introduced to make a total of four garbage collectors from which to choose.
Beginning with the J2SE platform, version 1.2, the virtual machine incorporated
a number of different garbage collection algorithms that are combined using
generational collection. While naive garbage collection examines every live
object in the heap, generational collection exploits several empirically
observed properties of most applications to avoid extra work.
The default collector in
HotSpot has two generations: the young generation and the tenured generation.
Most allocations are done in the young generation. The young generation is
optimized for objects that have a short lifetime relative to the interval
between collections. Objects that survive several collections in the young
generation are moved to the tenured generation. The young generation is
typically smaller and is collected more often. The tenured generation is
typically larger and collected less often.
The young generation
collector is a copying collector. The young generation is divided into 3 spaces:
eden-space, to-space, and from-space. Allocations are done from eden-space and
from-space. When those are full a young generation is collection is done. The
expectation is that most of the objects are garbage and any surviving objects
can be copied to to-space. If there are more surviving objects than can fit into
to-space, the remaining objects are copied into the tenured generation. There is
an option to collect the young generation in parallel.
The tenured generation is
collected with a mark-sweep-compact collection. There is an option to collect
the tenured generation concurrently.
This tip is based on FAQ
about Garbage Collection in the HotSpot Java Virtual Machine
and article "Tuning Garbage Collection with the 1.4.2 Java Virtual Machine"
Our older tips: March 22, 2001 - October 21, 2002
All published and not published on the site tips read
Printer Friendly Page
Send to a Friend
Search here again if you need more info!