Java JDK 21: JEP 439 - An Improved Generational Z Garbage Collector (ZGC)


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)



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.

Java JDK 21 JEP-439 Generational ZGC

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.

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap