What is Z Garbage Collector (ZGC)?
The Z Garbage Collector (ZGC) is a Java garbage collector designed for low-latency and high-scalability memory management. It helps to minimize the application pause times by efficiently reclaiming memory, making it suitable for real-time and responsive Java applications.
ZGC was introduced as an experimental feature in JDK 11 and became a production-ready feature in JDK 15 version.
The time-line of Z Garbage Collector (ZGC)
| Java Version | ZGC JEP | JEP Details |
|---|---|---|
| JDK 11 | JEP 333 | ZGC: A Scalable Low-Latency Garbage Collector (Experimental) |
| JDK 13 | JEP 351 | ZGC: Uncommit Unused Memory |
| JDK 14 | JEP 364 | ZGC on macOS |
| JDK 14 | JEP 365 | ZGC on Windows |
| JDK 15 | JEP 377 | ZGC: A Scalable Low-Latency Garbage Collector |
| JDK 16 | JEP 376 | ZGC: Concurrent Thread-Stack Processing |
| JDK 21 | JEP 439 | Generational ZGC |
What's new in JDK 21 - Z Garbage Collector (ZGC)?
JEP 439 introduces the Generational ZGC, which maintains separate generations for young and old objects.
This separation between generations enables for more frequent collection of young objects, improving application performance and thus reducing allocation stalls, heap memory overhead, and garbage collection CPU overhead, all while maintaining low pause times and minimal manual configuration.
The ultimate objective is to make Generational ZGC the default option and replace the non-generational version to reduce long-term maintenance costs.

Key Design Concepts:
- Generational ZGC splits the heap into young and old generations, collecting them independently to focus on young objects.
- Colored pointers, load barriers, and store barriers manage object references and ensure consistent object graph views.
- SATB (Snapshot at the Beginning) marking tracks references between objects during marking phases.
- Optimized barriers include fast paths, minimizing load barrier responsibilities, remembered-set barriers, and fused store barrier checks.
- Store barrier buffers and barrier patching reduce overhead in barrier code.
- Double-buffered remembered sets and dense heap regions optimize the handling of inter-generational pointers.
- Large objects can be allocated to the young generation and promoted if necessary.
- Full garbage collections involve young-generation collections alongside old-generation marking phases.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!