Java – Z Garbage Collector (ZGC)


Java – Z Garbage Collectors (ZDC)


”;


What is ZGC?

ZDC stands for Z Garbage Collector. Z Garbage Collector, ZDC was introduced with Java 11 as a low latency garbage collection mechnism. ZGC was introduced in Java 11 as an experimental feature as developer community felt it to be too large to be released early. 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.

Java 15 made the ZGC, Z Garbage Collector a standard feature. It was an experimental feature till Java 15. It is low latency, highly scalable garbage collector.

ZGC is highly performant and works efficiently even in case of massive data applications e.g. machine learning applications. It ensures that there is no long pause while processing the data due to garbage collection. It supports Linux, Windows and MacOS.

Features of Z Garbage Collector

With Java 16, ZGC Thread-Stack processing is moved from Safepoints to Concurrent Phase and improved its efficiency to great extent. Following are the enhancements made to garbage collection since then, for example −

  • 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.

  • Thread-stack processing moved from ZGC safepoints.

  • Stack processing is made lazy, cooperative, concurrent, and incremental.

  • All other per-thread root processing are removed from ZGC safepoints.

  • HotSpot subsystems can lazily process stacks.

  • Concurrent class unloading

  • Uncommiting of unused memory

  • Support for Class Data Sharing

  • NUMA Awareness

  • Multithreaded Heap Pre-touch

  • Max Heap Size limit from 4 TB to 16 TB.

Using Older way of Garbage Collection

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.

Advertisements

”;

Leave a Reply

Your email address will not be published. Required fields are marked *