logo

ZGC Enhancement


Show

The ZGC or Z Garbage Collector was launched with Java 11 as a short latency garbage collection mechanism. ZGC put together with security that Garbage Collection pause time is not depending on heap size. It will never surpass a 10 ms heap size. It doesn't matter whether it is 2MB or 2GB.

But ZGC had a restriction on returning unused heap memory to operating systems like other HotSpot VM GCs for example G1 and Shenandoah. Some enhancements that are done with Java 13 are given below:

  • ZGC gives back non-committed memory to the operating system by default until the highest heap size is outstretched.
  • ZGC provides performance enhancement by bringing down the memory footprint.
  • ZGC now assists heap size of 16 TB as differentiated to 4TB size limit.

We can use the below given example, In order to make a move back to Java 11 way of Garbage Collection

  • using -XX:-ZUncommit option
  • set -Xms and -Xmx heap size as the same.