After a heap size of 4,500 MB, the throughput starts to decrease slightly. At that point, the
application has reached the second trade-off: the additional memory has caused much longer
GC cycles, and those longer cycles—even though they are less frequent—can impact the
The data in this graph was obtained by disabling adaptive sizing in the JVM; the minimum
and maximum heap sizes were set to the same value. It is possible to run experiments on any
application and determine the best sizes for the heap and for the generations, but it is often
easier to let the JVM make those decisions (which is what usually happens, since adaptive
sizing is enabled by default).
Figure 6-3. Throughput with various heap sizes
Adaptive sizing in the throughput collector will resize the heap (and the generations) in order
to meet its pause time goals. Those goals are set with these flags: -XX:MaxGCPauseMillis= N
and -XX:GCTimeRatio= N .
The MaxGCPauseMillis flag specifies the maximum pause time that the application is will-
ing to tolerate. It might be tempting to set this to 0, or perhaps some very small value like 50
ms. Be aware that this goal applies to both minor and full GCs. If a very small value is used,