Java Reference
In-Depth Information
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-
ingHeapOccupancyPercent .
b. If additional CPU is available, adjust the number of threads via the Con-
cGCThreads flag.
c. To prevent promotion failures, decrease the size of the G1MixedGCCoun-
tTarget .
Advanced Tunings
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
this section.
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
Chapter 5 . If the JVM performs GC in the middle of that loop, some of those very-short-
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
Search WWH ::

Custom Search