1. G1 has a number of cycles (and phases within the concurrent cycle). A well-tuned
JVM running G1 should only experience young, mixed, and concurrent GC
2. Small pauses occur for some of the G1 concurrent phases.
3. G1 should be tuned if necessary to avoid full GC cycles.
The major goal in tuning G1 is to make sure that there are no concurrent mode or evacuation
failures that end up requiring a full GC. The techniques used to prevent a full GC can also be
used when there are frequent young GCs that must wait for a root region scan to complete.
Secondarily, tuning can minimize the pauses that occur along the way.
These are the options to prevent a full GC:
▪ Increase the size of the old generation either by increasing the heap space overall or by
adjusting the ratio between the generations.
▪ Increase the number of background threads (assuming there is sufficient CPU).
▪ Perform G1 background activities more frequently.
▪ Increase the amount of work done in mixed GC cycles.
There are a lot of tunings that can be applied here, but one of the goals of G1 is that it
shouldn't have to be tuned that much. To that end, G1 is primarily tuned via a single flag: the
same -XX:MaxGCPauseMillis= N flag that was used to tune the throughput collector.
When used with G1 (and unlike the throughput collector), that flag does have a default value:
200 ms. If pauses for any of the stop-the-world phases of G1 start to exceed that value, G1
will attempt to compensate—adjusting the young-to-old ratio, adjusting the heap size, start-
ing the background processing sooner, changing the tenuring threshold, and (most signific-
antly) processing more or fewer old generation regions during a mixed GC cycle.
The usual trade-off applies here: if that value is reduced, the young size will contract to meet
the pause time goal, but more frequent young GCs will be performed. In addition, the num-