Java / Java 17 Garbage Collection Interview Questions
What is a humongous object in G1 GC?
A humongous object is any object at least 50% the size of a single G1 region - large arrays are the most common example. Rather than being allocated normally into Eden, it's placed directly into one or more contiguous humongous regions reserved just for it.
This special-cases large allocations because copying a huge object during a normal evacuation pause would be disproportionately expensive; instead, humongous regions are typically reclaimed in bulk once the object becomes unreachable, without a copy step.
Frequent humongous allocations can still hurt performance by fragmenting the heap and triggering earlier, more frequent concurrent cycles - a common fix is increasing -XX:G1HeapRegionSize so fewer objects cross the 50% humongous threshold.
More Related questions...