G1, a new garbage collector for Java 7
A brand-new type of garbage collector (GC) has been prepared for Java 7. It’s called G1 (Garbage First), and it promises to bring GC behavior closer to soft real-time. Besides more predictable application pauses, another goal is to reduce frequent full-heap collections, during which the application can’t respond. A third is to reduce the impact of GC on application performance. G1 differs from existing collectors in how it organizes and manages memory.
Conventional HotSpot collectors of the Concurrent Mark-Sweep type divide the heap strictly into generations, young and tenured. The assumption is that young objects die sooner. If an object survives several collections, it moves into the tenured area, where collection happens less often. G1 doesn’t impose this strict division. Instead, it divides memory into relatively small regions. G1 works through those regions and collects those with the most dead objects, copying the survivors to other regions.
Before pointing you toward more information on G1, I recommend skimming the presentation Garbage Collection-Friendly
Programming, which is full of useful tips and clears up myths about things like nulling object references and pooling objects.
More about G1
Related articles
Related CZ Podcast episodes
- #3 · Java 6 SE, Vývoj webových aplikací
Dagi and Filemon discuss Java 6 and web application frameworks. · Czech audio
- #1 · Vývojová prostředí v Javě
The first CZ Podcast episode looks at Java development environments. · Czech audio