Paul Krill
Editor at Large

Generational garbage collection promises to boost Java performance

Generational Z Garbage Collector would lower garbage collection CPU overhead, lower heap memory overhead, and reduce the risk of allocations stalls, OpenJDK proposal says.

Java / coffee / beans / production / processing
Credit: Gregory Hayes

A proposal floating in the Java community would improve application performance by extending the ZGC (Z Garbage Collector) to maintain separate generations for young and old objects. This would allow ZGC to more frequently collect young objects, which tend to die young, Java’s developers said.

Specific goals of the OpenJDK Java Enhancement Proposal (JEP) for generational ZGC include lower risks of allocation stalls, lower required heap memory overhead, and lower garbage collection CPU overhead. These benefits should come without significant throughput reduction compared to non-generational ZGC, the proposal states.

Designed for scalability and low latency, ZGC has been available as a production release since Java Development Kit (JDK) 15 in September 2020. With ZGC, most work is done with application threads running. Pause times for ZGC consistently are measured in microseconds, whereas pause times for the default G1 collector range from milliseconds to seconds. Thus, for many workloads, ZGC can solve latency problems related to garbage collection, the proposal states.

ZGC works well when there are sufficient resources. But because ZGC stores all objects together, regardless of age, it must collect all objects every time it runs. Because young objects tend to die young, while older objects tend to stay around (per the weak generational hypothesis), collecting young objects requires fewer resources and yields more memory while collecting old objects takes more resources and yields less memory.

Generational ZGC is currently not designated for any specific version of standard Java. The current release, JDK 20, arrived a week ago while the next release, JDK 21, is due in September. Standard Java is on a six-month release cadence.

Paul Krill

Paul Krill is editor at large at InfoWorld. Paul has been covering computer technology as a news and feature reporter for more than 35 years, including 30 years at InfoWorld. He has specialized in coverage of software development tools and technologies since the 1990s, and he continues to lead InfoWorld’s news coverage of software development platforms including Java and .NET and programming languages including JavaScript, TypeScript, PHP, Python, Ruby, Rust, and Go. Long trusted as a reporter who prioritizes accuracy, integrity, and the best interests of readers, Paul is sought out by technology companies and industry organizations who want to reach InfoWorld’s audience of software developers and other information technology professionals. Paul has won a β€œBest Technology News Coverage” award from IDG.

More from this author