Video in progress
Shenandoah and ZGC are both low-pause GCs. How do they differ, and when do you choose each?
Shenandoah / ZGC — Developed by: Red Hat / Oracle; Concurrent relocation mechanism: forwarding pointer + load-reference barrier / colored pointer + load barrier; Compressed oops: yes / no; Generational mode: experimental in JDK 24, product since JDK 25 / Java 21+, default since 23; Distributions: most OpenJDK builds…
📖 Answer
| Shenandoah | ZGC | |
|---|---|---|
| Developed by | Red Hat | Oracle |
| Concurrent relocation mechanism | forwarding pointer + load-reference barrier | colored pointer + load barrier |
| Compressed oops | yes | no |
| Generational mode | experimental in JDK 24, product since JDK 25 | Java 21+, default since 23 |
| Distributions | most OpenJDK builds, not in Oracle JDK | all JDK 15+ |
In practice, the difference looks like this to me:
- 4-16 GB heap, many small objects: Shenandoah uses less memory thanks to compressed oops and works well;
- tens or hundreds of GB of heap, sub-millisecond pause requirement: generational ZGC;
- if you use Oracle JDK, there is no Shenandoah at all, so the choice makes itself: ZGC.
Both share a downside: compared to G1 they take more CPU, and if allocation is very fast, the GC can't keep up. In Shenandoah this shows up as a "degenerated GC" and finally a Full GC, in ZGC as an allocation stall.
The only reliable way to decide is to test with real load: compare p99/p999 latency, CPU usage and RSS across all three GCs (G1, Shenandoah, ZGC). For many services G1 alone turns out to be enough.
Sign up to mark studied questions and save your progress.