Java SE technologies provide the functionality to develop and run applications
» Get Java SE
The Garbage-First Garbage CollectorThe Garbage-First Garbage Collector (or G1 GC for short) is a new GC that is being introduced in the Java HotSpot VM in JDK 7. An experimental version of G1 has also been released in Java SE 6 Update 14. G1 is the long-term replacement for HotSpot's low-latency Concurrent Mark-Sweep GC (widely referred to as CMS). AttributesG1 is a “server-style” GC and has the following attributes.
DescriptionG1 takes a very different approach to heap layout than other HotSpot GCs. In G1, there is no physical separation between the young and old generations. Instead, there is a single contiguous heap which is split into same-sized regions. The young generation is a set of potentially non-contiguous regions, and the same is true for the old generation. This allows G1 to flexibly move resources as needed from the old to the young generation, and vice versa. Collection in G1 takes place through evacuation pauses, during which the survivors from a set of regions referred to as the collection set are evacuated to another set of regions (the to-space) so that the collection set regions can then be reclaimed. Evacuation pauses are done in parallel, with all available CPUs participating. Most evacuation pauses collect the available young regions, thus are the equivalent of young collections in other HotSpot GCs. Occasionally, select old regions may also be collected during these pauses because G1 piggybacks old generation collection activity on young collections. Like CMS, G1 periodically performs a concurrent marking phase. The main role of this phase is to identify which old regions are mostly full of garbage objects, as these are the most efficient and desirable to collect. Unlike CMS, G1 does not perform a concurrent sweeping phase. Instead, the most profitable old regions identified by the concurrent marking phase are collected during subsequent evacuation pauses (the piggybacking mentioned above). Using G1G1 is still considered experimental and can be enabled with the following two parameters:
To set a GC pause time goal, use the following parameter:
With G1, a time interval can be specified during which a GC pause should last no longer than the time given above:
Note that the above two options represent goals, not promises or guarantees. They might work well in some situations but not in others, and the GC might not always be able to obey them. Alternatively, the size of the young generation can be specified explicitly to impact evacuation pause times:
G1 also uses the equivalent of survivor spaces, which are, naturally, a set of (potentially non-contiguous) regions. Their size can be specified with the usual parameters (e.g., Finally, to run G1 at its full potential, try setting these two parameters which are currently disabled by default because they may uncover a rare race condition:
One more thing to note is that G1 is very verbose compared to other HotSpot GCs when StatusG1 development is now focused primarily on resolving any remaining reliability issues and improving performance, and also on removing the following limitations:
Resources
|
Related ResourcesRelated DownloadsPopular Topics
Sun ResourcesRelated SitesGetting Started? | ||||||||||
|
| ||||||||||||