Video in progress
"to-space exhausted" or "Evacuation Failure" shows up in the G1 log. What does it mean and what do you do?
A young or mixed GC couldn't find a free region to copy the live objects into. G1 leaves the objects in place and the pause gets much longer, and often a Full GC follows. It is a sign that the heap isn't big enough for the live data.
📖 Answer
During a collection G1 copies live objects from eden to survivor or old regions (evacuation). For that it needs spare free regions. When they run out:
[gc] GC(512) Pause Young (Normal) (G1 Evacuation Pause) (Evacuation Failure: Allocation) 3980M->3975M(4096M) 1245.6ms
Older versions logged the same thing as to-space exhausted. The signs: the pause is many times longer than usual, and the heap barely shrank after the GC.
The causes:
- the heap is too small for the live data, the most common case;
- a load spike: the allocation rate suddenly rose and many objects survived out of the survivor spaces;
- humongous objects took over regions;
- marking starts too late and old isn't cleaned in time.
What I do:
- I look at the post-GC heap trend in the GC log. If it keeps growing, it isn't a tuning issue but a leak.
- If not, I increase the heap, which is the most correct fix.
- I raise
-XX:G1ReservePercent(default 10) to have more spare regions. - I lower
-XX:InitiatingHeapOccupancyPercentor raiseConcGCThreadsso that marking starts earlier and runs faster.
One or two occurrences at a load peak are normal. If it keeps repeating, the service needs more memory.
Sign up to mark studied questions and save your progress.