Search code examples
javagarbage-collectionjvmg1gc

G1: What are the differences between mixed gc and full gc?


For garbage first collector, young gc means performing gc in young generation only and mixed gc would clean both young and old generation.

So what is full gc? Why it lasts longer than mixed gc?

I've done some searching but I didn't find any post that explains full gc.


Solution

  • From Oracle G1 GC blog and technetwork article

    Young GC:

    The collection set of the Young GC includes only young/survivor regions.

    Mixed GC:

    The collection set of the Mixed GC includes both young/survivor regions, but also old regions.

    Humongous Objects and Humongous Allocations

    For G1 GC, any object that is more than half a region size is considered a "Humongous object". Such an object is allocated directly in the old generation into "Humongous regions". These Humongous regions are a contiguous set of regions.

    Dead Humongous objects are freed at the end of the marking cycle during the cleanup phase also during a full garbage collection cycle.

    In-order to reduce copying overhead, the Humongous objects are not included in any evacuation pause. A full garbage collection cycle compacts Humongous objects in place.

    Generally a Full GC cleans the entire Heap – both Young and Tenured spaces (old gen)

    On a different note, you have to worry about how much time "application threads were stopped" irrespective of GC type : Young GC or Full GC etc.