JVM garbage collection using ZGC
The Z Garbage Collector (ZGC) is a low-latency garbage collector that is well-suited for large Java Virtual Machine (JVM) heaps. PingDirectory supports both the non-generational and generational types of ZGC.
For the rest of this article, "ZGC" indicates the non-generational type of garbage collection and "Generational ZGC" indicates the generational type. |
Supported JDK versions
Of the supported JDK versions for PingDirectory, ZGC requires at least JDK 17 (for full support) and Generational ZGC requires at least JDK 21. Learn more about the JDK version requirements for ZGC in the OpenJDK Wiki.
Heap space recommendations
These recommendations apply to both ZGC and Generational ZGC. |
In the JVM startup arguments, you should configure the heap space with at least 20 - 25% headroom space left for the system RAM. For example, for a server with 62 GB RAM, the xmx
and xms
arguments in the start-server.java-args
argument of the java.properties
file should be set to 45 GB, expressed by -Xmx45g -Xms45g
.
ZGC
ZGC is a single-generation, region-based, NUMA-aware, compacting collector. Like G1, ZGC works concurrently with the JVM application. ZGC doesn’t track the number of collection cycles that objects in the heap have survived. Because each region of the heap is concurrently scanned in each cycle, objects aren’t sorted into new or old generations. This collector is suitable for applications with large amounts of memory that require short pause times, as it does not pause the execution of application threads for more than 10 ms.
The recommended JVM properties when using ZGC for garbage collection are:
-XX:+UseZGC -XX:ConcGCThreads=10 -XX:InitiatingHeapOccupancyPercent=80 -XX:MaxNewSize=2g -XX:NewSize=2g
Generational ZGC
In contrast to ZGC, Generational ZGC does separate the heap into new and old generations to optimize the collection process.
The recommended JVM properties when using Generational ZGC for garbage collection are:
-XX:+UseZGC -XX:+ZGenerational -XX:ConcGCThreads=10 -XX:InitiatingHeapOccupancyPercent=80 -XX:MaxNewSize=2g -XX:NewSize=2g
Learn more about Generational ZGC in HotSpot Virtual Machine Garbage Collection Tuning Guide in the Oracle Java documentation.