Quick revision
The short answer
Shenandoah is a region-based collector that, like ZGC, compacts the heap concurrently, so its pauses do not grow with heap size, while G1 still copies objects inside stop-the-world pauses. It uses load reference barriers and forwarding information in the object header so application threads always see the moved copy of an object during concurrent evacuation, and unlike ZGC it supports compressed oops, which helps footprint on heaps under 32 GB. It was developed by Red Hat and ships in many OpenJDK builds such as Red Hat's, Amazon Corretto and Eclipse Temurin, but not in Oracle JDK builds; a generational mode was experimental in JDK 24 and became a product feature in JDK 25, so check your build.
What to remember
In this answer, we saw that Shenandoah, like ZGC, compacts concurrently so its pauses stay short regardless of heap size, while G1 copies in stop-the-world pauses. Load reference barriers and forwarding information in the object header let application threads always reach the new copy of an object during concurrent evacuation. Unlike ZGC it supports compressed oops, which saves memory on heaps under 32 GB. It came from Red Hat and ships in most OpenJDK-based builds but not in Oracle JDK builds, and its generational mode became a product feature in JDK 25, so we check the exact build we deploy.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
Shenandoah is a region-based collector that, like ZGC, compacts the heap concurrently, so its pauses do not grow with heap size, while G1 still copies objects inside stop-the-world pauses. It uses load reference barriers and forwarding information in the object header so application threads always see the moved copy of an object during concurrent evacuation, and unlike ZGC it supports compressed oops, which helps footprint on heaps under 32 GB. It was developed by Red Hat and ships in many OpenJDK builds such as Red Hat's, Amazon Corretto and Eclipse Temurin, but not in Oracle JDK builds; a generational mode was experimental in JDK 24 and became a product feature in JDK 25, so check your build.
Why this question is asked
When teams look for a low-pause collector, they usually find ZGC first, and then someone mentions Shenandoah. The two aim at the same goal, but they get there differently and are not available in the same places. Interviewers ask this to see whether we know the design differences and the practical catch: whether the collector exists in the JDK we actually run. In this answer, we will recap what G1 does in its pauses, see how Shenandoah evacuates concurrently, compare it with ZGC, and check which builds include it.
1A Quick Recap: Where G1 Spends Its Pauses
G1 divides the heap into regions and collects by evacuation: it copies live objects out of a set of regions and frees them. Marking the old generation is concurrent, but the copying itself happens in stop-the-world pauses. So a G1 pause grows with the amount of live data it has to copy, and with large live sets it can take tens or hundreds of milliseconds.
Both Shenandoah and ZGC move the copying out of the pause. That is what concurrent compaction means: objects are moved while the application keeps running, and the pauses only handle the hand-over between phases.
2How Shenandoah Evacuates Concurrently
Shenandoah's cycle starts with a short init mark pause, then marks concurrently, then a short final mark pause chooses the collection set, the regions with the most garbage. Then comes concurrent evacuation: GC threads copy live objects out of those regions while the application runs. After that, a concurrent update-references phase walks the heap and replaces old addresses with new ones, and short pauses close it off.
The danger during evacuation is that an application thread uses the old copy of an object, for example writing to it after the new copy was made, so the write would be lost. Shenandoah prevents this with a load reference barrier: whenever the application loads a reference from the heap and the object may be in the collection set, the barrier checks whether the object has been forwarded. If it has, the barrier returns the new copy. If not, the application thread copies the object itself and installs the forwarding.
The forwarding information lives in the object's own header. Early Shenandoah versions used a separate forwarding pointer word in front of every object, known as a Brooks pointer, which cost memory; since JDK 13 the forwarding address is stored in the mark word of the old copy, and load reference barriers replaced the earlier read and write barriers.
- Init markshort pause
- Concurrent marktrace live objects
- Final markshort pause: pick collection set
- Concurrent evacuationcopy live objects; barriers return new copies
- Concurrent update referencesrewrite old addresses across the heap
- Final update refsshort pause
- Concurrent cleanupfree evacuated regions
7 steps in order. Play them, or step through them one at a time.
Phase names differ slightly between releases; recent versions have removed or shortened some pauses.
3Compressed Oops: A Practical Difference From ZGC
Compressed oops are 32-bit object references that HotSpot uses when the heap is under about 32 GB; each reference takes 4 bytes instead of 8. For a typical object graph full of references, that saves 20 to 30 percent of heap.
ZGC keeps metadata bits, its colours, inside every 64-bit pointer, so it cannot use compressed oops. Shenandoah stores its metadata in object headers and side tables instead, so it can. For a service with a 16 GB heap, that means the same data takes noticeably less memory under Shenandoah than under ZGC. For a 200 GB heap the difference does not apply, because no collector uses compressed oops at that size.
4Comparing the Three Collectors
Put side by side, the differences come down to where copying happens, which barriers run, and availability.
| Aspect | G1 | ZGC | Shenandoah |
|---|---|---|---|
| Copying | in stop-the-world pauses | concurrent | concurrent |
| Typical pause | 10-200 ms, grows with live data | under 1 ms | a few ms or less |
| Key barrier | card-marking post-write | load barrier on coloured pointers | load reference barrier |
| Compressed oops | yes | no | yes |
| Generational | yes | yes, only mode since JDK 24 | product mode since JDK 25 |
| In Oracle JDK builds | yes | yes | no |
5Which JDK Builds Include It
Shenandoah was developed by Red Hat and entered upstream OpenJDK in JDK 12 through JEP 189, as an experimental feature, and became a product feature in JDK 15 through JEP 379. Red Hat also backported it to its JDK 8 and 11 builds. Builds made from OpenJDK sources, such as Red Hat's builds, Amazon Corretto, Eclipse Temurin and Azul Zulu, generally include it. Oracle's own JDK builds are compiled without it, so -XX:+UseShenandoahGC fails at startup there.
Generational Shenandoah arrived as an experimental mode in JDK 24 (JEP 404) and became a product feature in JDK 25 (JEP 521), enabled with -XX:+UseShenandoahGC -XX:ShenandoahGCMode=generational. Vendors decide what to ship, so the simplest check is to run the flag on the exact image we deploy.
6Follow-up questions
How would you compare Shenandoah and ZGC for a given service?
I would run the same production-like load against both, on the same build and instance type, with the same heap, and compare tail latency, GC CPU, allocation stalls or pacing delays, and memory use. For heaps under 32 GB, Shenandoah's compressed oops may let it use less memory for the same data. For very large heaps, ZGC's pauses are the most consistent. I would also weigh availability: if half the fleet's builds lack Shenandoah, ZGC's universal availability is a real advantage.
What happens when Shenandoah falls behind?
It first paces allocating threads, slowing them down a little in proportion to how far the collector is behind. If that is not enough, it runs a degenerated cycle, finishing the current cycle in a stop-the-world pause, and as a last resort a full GC. In the logs these appear as Pause Degenerated GC and Pause Full, and seeing them means the collector needs more headroom or CPU.
Does Shenandoah need many tuning flags?
Usually not. It chooses a heuristic, adaptive by default, that decides when to start cycles based on allocation rate and free memory. As with ZGC, the main decision is enough heap headroom.
7Conclusion
In this answer, we saw that Shenandoah, like ZGC, compacts concurrently so its pauses stay short regardless of heap size, while G1 copies in stop-the-world pauses. Load reference barriers and forwarding information in the object header let application threads always reach the new copy of an object during concurrent evacuation. Unlike ZGC it supports compressed oops, which saves memory on heaps under 32 GB. It came from Red Hat and ships in most OpenJDK-based builds but not in Oracle JDK builds, and its generational mode became a product feature in JDK 25, so we check the exact build we deploy.
Open with
Shenandoah is a region-based collector like G1, but the important difference is that it evacuates concurrently. G1 marks concurrently and then copies live objects inside stop-the-world pauses, so its pauses grow with live data.
Then, if they want more
Shenandoah and ZGC both copy while the application runs, so their pauses stay short regardless of heap size.
Shenandoah makes this safe with a load reference barrier: when the application loads a reference to an object that may be in the collection set, the barrier checks the forwarding information in the object's header and returns the new copy, or copies the object itself if no one has yet.
Since JDK 13 the forwarding address lives in the mark word, so there is no extra word per object. Compared with ZGC, the practical difference is compressed oops: ZGC stores its colour bits in 64-bit pointers and cannot use them, while Shenandoah can, which saves a lot of memory on heaps under 32 GB.
On availability, Shenandoah was developed by Red Hat and is in most OpenJDK builds such as Red Hat's, Corretto and Temurin, but Oracle JDK builds leave it out. Its generational mode was experimental in JDK 24 and a product feature in JDK 25, so I always check the exact image we deploy before adopting it.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 25, Java 24, Java 12, Java 13
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- HotSpot Garbage Collection Tuning Guide, JDK 21
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "How does Shenandoah differ from G1 and ZGC, and which JDK builds include it?": https://scrivio-interview-library.netlify.app/java/garbage-collection/33d706246f/