Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 231
Neo Avatar asked Feb 13 '16 13:02

Neo


People also ask

What is a full GC?

Full GC is an important phase in the garbage collection process. During this full GC phase, garbage is collected from all the regions in the JVM heap (Young, Old, Perm, Metaspace). During this phase, the JVM is paused.

How does G1 GC work?

G1 GC uses the Snapshot-At-The-Beginning (SATB) algorithm, which takes a snapshot of the set of live objects in the heap at the start of a marking cycle. The set of live objects is composed of the live objects in the snapshot, and the objects allocated since the start of the marking cycle.

Why is G1 GC better?

One difference is that G1 is a compacting collector. Also, G1 offers more predictable garbage collection pauses than the CMS collector, and allows users to specify desired pause targets. As with CMS, G1 is designed for applications that require shorter GC pauses.

How many types of GC are there?

Two types of gas chromatography are encountered: gas-solid chromatography (GSC) and gas-liquid chromatography (GLC).


1 Answers

Under normal conditions G1 should only run young and mixed collections to meet its pause time goals.

Full GCs are a fallback mechanism and likely to violate those goals. They occur when mixed GCs aren't able to keep up with allocations, when a humongous allocation could not be satisifed or when a GC is requested with System.gc() and some other conditions.

Logging with -XX:+PrintGCDetails should include a cause for full collections.

like image 166
the8472 Avatar answered Sep 16 '22 17:09

the8472