BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News JEP 474: Generational Mode Now Standard for ZGC in Java

JEP 474: Generational Mode Now Standard for ZGC in Java

JEP 474, ZGC: Generational Mode by Default, has been Targeted for JDK 23. This JEP proposes to use the Z Garbage Collector (ZGC) from non-generational to generational mode by default. The non-generational mode will be deprecated and removed in a future JDK release. This will ultimately reduce the cost of maintaining the two modes, so future development can primarily focus on JEP 439, Generational ZGC.

Perhaps the most significant change in JEP 474 is the switch of the ZGenerational option’s default value from false to true. This clearly signals a strategic change in Java's approach to memory management, specifically optimizing garbage collection based on delivering more ‘free’ memory to Java applications and a lower overhead of GC.

This transition to generational mode by default is motivated by the desire to reduce the maintenance work of supporting generational and non-generational modes alike. With this focus on performance, the OpenJDK team will make the generational ZGC more efficient and effective as they evolve to handle the expectations of modern Java applications.

Developers should be aware that the non-generational mode is still available but deprecated. Warnings will be issued if the non-generational mode is explicitly enabled via command-line options. The fact that non-generational mode is being deprecated is a sign that this will be removed in the future.

Consider the typical command-line arguments:

  • -XX:+UseZGC: Now defaults to using Generational ZGC.
  • -XX:+UseZGC -XX:+ZGenerational: It also uses Generational ZGC but with a deprecation warning for the ZGenerational flag.
  • -XX:+UseZGC -XX:-ZGenerational: Uses non-generational ZGC with a deprecation warning for the ZGenerational flag and an advisory that non-generational mode is deprecated for removal.

Developers should test their applications to ensure compatibility and performance under the new default setting. If applications are tightly integrated with the JVM and are particularly sensitive to garbage collection behaviour, they might see changes to their performance.

OpenJDK's testing commitment ensures that existing configurations and benchmarks perform as expected with the new default. The risk is relatively low for most applications, but specific high-performance or low-latency applications might require adjustments to their configuration.

JEP 474 marks a pivotal update in Java's ongoing development. It aims to streamline and improve the garbage collection process, focusing on generational techniques. This update will require developers to reassess their applications' compatibility and performance, but it promises a more efficient management of Java applications in the long run.

About the Author

Rate this Article

Adoption
Style

BT