ZGC is a low pause time or low latency Garbage collector designed to handle modern workloads where memory is not limited to GBs. In the cases, where heap size is in Terabytes it is important to keep pause times low when garbage collector runs. ZGC address the very issue. ZGC can handle up to 4TB of heap.
ZGC was introduced in JDK 11 with improvements in later versions. ZGC comes in 64-bit only, Will explain why in a bit.
To enable use following JVM args
ZGC is expected to ensure following
ZGC uses the term Pointer Coloring that utilises the virtual memory address space using 64-bit addressing. Out of 64-bit, 42 bits are used to address actual memory and rest 22 bits are reserved for maintaining pointer state. Out of 22 reserved states, 4 consecutive bits are used only. These 4 bits are named as finalizable, remap, mark0 and mark1. These bits are set or unset in GC cycles.
Since there is some extra bits are set in the address, ZGC requires to decode or deference actual address from the coloured pointer. This technique is called Multi-mapping.
There are two phases of in garbage collection - Marking and Relocation.
This step is a stop-the-world phase but this would be a low pause as only a small set of live objects (Objects accessible from GC roots) are relocated in this phase.
In the next phase all the remaining live set is relocated concurrently.