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:
We can use the below given example, In order to make a move back to Java 11 way of Garbage Collection