1. G1 tuning should begin by setting a reasonable pause time target.
2. If full GCs are still an issue after that and the heap size cannot be increased, spe-
cific tunings can be applied for specific failures.
a. To make the background threads run more frequently, adjust the Initiat-
b. If additional CPU is available, adjust the number of threads via the Con-
c. To prevent promotion failures, decrease the size of the G1MixedGCCoun-
This section on tunings covers some fairly unusual situations. Even if those situations are not
encountered frequently, many of the low-level details of the GC algorithms are explained in
Tenuring and Survivor Spaces
When the young generation is collected, some objects will still be alive. This includes newly
created objects that are destined to exist for a long time, but it also includes some objects that
are otherwise short-lived. Consider the loop of BigDecimal calculations at the beginning of
lived BigDecimal objects will be quite unlucky: they will have been just created and in use,
so they can't be freed—but they aren't going to live long enough to justify moving them to
the old generation.
This is the reason that the young generation is divided into two survivor spaces and eden.
This setup allows objects to have some additional chances to be collected while still in the
young generation, rather than being promoted into (and filling up) the old generation.
When the young generation is collected and the JVM finds an object that is still alive, that
object is moved to a survivor space rather than to the old generation. During the first young