Java 13 - ZGC Enhancements

The ZGC or Z Garbage Collector was introduced with Java 11 as a low latency garbage collection mechnism. ZGC makes sure that Garbage Collection pause time is not dependent on heap size. It will never exceed 10 ms no matter heap size is 2MB or 2GB.

But ZGC had a limitation on returning unused heap memory to operating system like other HotSpot VM GCs such as G1 and Shenandoah. Following are the enhancements done with Java 13:

  • ZGC returns uncommited memory to operating system by default until the maximum heap size is reached.

  • ZGC gives performance improvement with a reduced memory footprint.

  • ZGC now supports heap size of 16 TB as compared to 4TB size limit.

In order to move back to Java 11 way of Garbage Collection, we can use following options:

  • using -XX:-ZUncommit option

  • set -Xms and -Xmx heap size as same.