Quick revision
The short answer
G1 ran out of free regions to copy surviving and promoted objects into during a young collection, so the evacuation failed. It kept the objects that could not be copied in place, finished the pause, and then, with no free space left, fell back to a full compacting collection of the whole heap, which takes seconds. The usual causes are a live set too close to the maximum heap, concurrent marking starting too late so mixed collections fall behind, or bursts of humongous allocations, and the fixes are more heap, earlier marking or a larger reserve, more concurrent GC threads, and less allocation or live data.
What to remember
In this answer, we saw that an evacuation failure, shown as to-space exhausted or an evacuation failure tag depending on the JDK, means G1 had no free regions left to copy surviving objects into. It leaves those objects in place, ends the pause with the heap still nearly full, and then falls back to a full compacting collection that stops the application for seconds. The usual causes are a live set too close to the maximum heap, concurrent marking that starts too late, and humongous allocation bursts, and the fixes are more heap or less live data, an earlier marking start or larger reserve, more concurrent GC threads, and less allocation.
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.
G1 ran out of free regions to copy surviving and promoted objects into during a young collection, so the evacuation failed. It kept the objects that could not be copied in place, finished the pause, and then, with no free space left, fell back to a full compacting collection of the whole heap, which takes seconds. The usual causes are a live set too close to the maximum heap, concurrent marking starting too late so mixed collections fall behind, or bursts of humongous allocations, and the fixes are more heap, earlier marking or a larger reserve, more concurrent GC threads, and less allocation or live data.
Background to this question
A multi-second G1 full GC is one of the most visible GC incidents a service can have: request threads freeze, health checks time out, and load balancers may take the instance out of rotation. The log lines before it almost always tell the story, if we know how to read them. In this answer, we will recap how G1 evacuates, walk through what happens when evacuation fails, look at the three typical causes and how to tell them apart, and then go through the fixes.
1A Quick Recap of Evacuation
G1 collects by evacuation. During a pause, it copies the live objects of the regions it is collecting into free regions, then frees the source regions. A young collection copies live eden objects into survivor regions, and objects that are old enough into old regions. A mixed collection also copies live objects out of selected old regions.
So every pause needs free regions as destinations before it can free anything. Normally there are plenty. G1 even keeps a reserve, G1ReservePercent, 10 percent of the heap by default, which it tries to keep free for exactly this purpose.
2What Happened in This Pause
In our case, the young collection started copying, and at some point there was no free region left to copy into. The log marks this with to-space exhausted on older JDKs or an evacuation failure tag on newer ones. Here is how the sequence typically looks; the exact wording differs between JDK versions, so check your version's messages.
8 messages in order. Play them, or step through them one at a time.
When an object cannot be copied, G1 leaves it where it is and marks it as forwarded to itself. The region it lives in cannot be freed, so it is kept and turned into an old region. Handling those self-forwarded objects adds time to the pause, which is why the young pause took 412 ms instead of the usual 30 ms.
Notice that the heap did not shrink. After the failed pause there were still almost no free regions, so the next allocation could not be satisfied. G1 then ran a full GC: it marked the whole heap and slid live objects together, which works without free regions but touches everything. Since JDK 10 this full GC is parallel, yet on a 4 GB heap with 2.7 GB live it still took nearly five seconds.
3The Three Typical Causes
The first cause is a live set too close to the maximum heap. In our log the full GC left 2,780 MB live out of 4,096 MB, about 68 percent. G1 needs room for eden, survivors, the reserve and garbage that has not been reclaimed yet; once the live data passes roughly 70 percent of the heap, any burst of allocation can exhaust it. The fix here is heap size or live data, not tuning.
The second cause is concurrent marking starting too late. Old regions are only cleaned by mixed collections, and mixed collections can only run after marking finishes. If marking starts at 80 percent occupancy and takes 20 seconds while the application promotes 50 MB per second, the old generation grows by 1 GB before any old region is reclaimed. Adaptive IHOP usually prevents this, but a sudden change in load, such as a cache warming after a deploy, can outrun its predictions. The log shows it as Concurrent Mark Cycle lines that end just before, or never finish before, the failure.
The third cause is bursts of humongous allocations. Large arrays need contiguous free regions and count as old occupancy at once, so a burst of them can consume the free regions quickly and fragment what remains. The log shows G1 Humongous Allocation causes and a rising humongous region count in the pauses just before the failure.
4Fixing It
Once we know the cause, the fixes follow. For a live set that is too large, give the JVM more heap, for example by raising MaxRAMPercentage or the container limit, or reduce the live data by bounding caches and dropping data the service does not need to keep. As a guide, keep the live set below about half to two thirds of the maximum heap.
For marking that starts too late, start it earlier and keep more space free. We can raise the reserve with -XX:G1ReservePercent=15, which also feeds adaptive IHOP, or turn adaptive IHOP off and set a fixed lower threshold. If marking simply takes too long, give it more concurrent threads with -XX:ConcGCThreads, which by default is about a quarter of the parallel GC threads.
For humongous bursts, fix the allocation: stream or chunk large buffers so they stay below half a region, or raise G1HeapRegionSize to reduce how many objects count as humongous. In every case, also look at the allocation and promotion rate. A heap that is 30 percent bigger only delays the failure if the application keeps more and more data alive.
5Follow-up questions
How would you confirm whether humongous allocations were the trigger?
I would enable -Xlog:gc+heap=info, which prints region counts by type at every pause, and look at the humongous count in the pauses before the failure. If it climbs from a handful to hundreds, and pauses with the cause G1 Humongous Allocation appear, humongous objects were at least a large part of it. A JFR recording then shows allocations outside TLABs with sizes and stack traces, which names the code that created them. If humongous counts stay low, I look at marking timing and the live set instead.
Is an evacuation failure always followed by a full GC?
No. If the failed young pause still freed enough regions, for example because most of eden was garbage, the application continues and later pauses recover. The full GC follows when the heap is effectively full after the failed pause. Recent JDKs have also made evacuation failure handling much cheaper, so an isolated one may be a warning rather than an outage.
Why does heap usage go up in the failed pause?
Because objects that failed to copy stay where they are, so the regions holding them cannot be freed and become old regions, while the objects that were copied before the failure now also occupy their new destination regions. Part of the data is counted twice until the next collection, so used heap can end higher than it started, which is a reliable sign of a failed evacuation.
6Conclusion
In this answer, we saw that an evacuation failure, shown as to-space exhausted or an evacuation failure tag depending on the JDK, means G1 had no free regions left to copy surviving objects into. It leaves those objects in place, ends the pause with the heap still nearly full, and then falls back to a full compacting collection that stops the application for seconds. The usual causes are a live set too close to the maximum heap, concurrent marking that starts too late, and humongous allocation bursts, and the fixes are more heap or less live data, an earlier marking start or larger reserve, more concurrent GC threads, and less allocation.
Open with
To-space exhausted, or evacuation failure in newer JDKs, means that during the young pause G1 ran out of free regions to copy surviving and promoted objects into. It cannot simply stop, so it leaves those objects in place, self-forwarded, keeps their regions as old regions and finishes the pause.
Then, if they want more
That pause is slower than usual and frees little, so the heap is still nearly full, the next allocation fails, and G1 falls back to a full compacting collection of the entire heap, which is the several-second Pause Full (G1 Compaction Pause). I would look for three causes.
First, the live set is too close to the maximum heap; the heap after the full GC tells me that, and if it is above about two thirds of the heap I need more heap or less live data.
Second, concurrent marking started too late, so mixed collections never caught up; I would check when marking cycles started and ended, and fix it with a larger G1ReservePercent, a lower fixed IHOP, or more ConcGCThreads.
Third, bursts of humongous allocations, which I would confirm with gc+heap logs showing the humongous region count and JFR allocation events, and fix by streaming or chunking buffers. The exact log wording changes between JDK versions, so I check the messages for the version we run.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Java 10
- 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 "G1 logs for a service show a young pause marked with to-space exhausted or evacuation...": https://scrivio-interview-library.netlify.app/java/garbage-collection/1e18c59834/