Java FAQ: Top Questions
70. What is the pause mechanism in ZGC?
ZGC (Z Garbage Collector), introduced as experimental in Java 11 and production-ready in Java 15, is a low-latency GC with pause times typically under 1ms, achieved through a unique pause mechanism.
- Concurrent Operations: Most GC work (marking, relocation) is concurrent with application threads.
- Pause Types: Short stop-the-world pauses for root scanning and relocation set selection.
- Colored Pointers: Uses pointer metadata to track object states, enabling concurrent relocation.
- Load Barriers: Application threads use barriers to handle relocated objects, reducing pause needs.
- Use Case: Latency-sensitive applications, like trading or real-time systems.