Table 6-2. Effect of dynamic GC tuning
End heap size Percent time in GC OPS
Xmx=3560M ; MaxGCRatio=19 2.1 GB
In a test that spends a significant amount of time in GC, things are different. The JVM will
never be able to satisfy the 1% throughput goal in this test; it tries its best to accommodate
the default goal and does a reasonable job, using 1.7 GB of space.
Things are worse when an unrealistic pause time goal is given. To achieve a 50 ms collection
time, the heap is kept to 588 MB, but that means that GC now becomes excessively frequent.
Consequently, the throughput has decreased significantly. In this scenario, the better per-
formance comes from instructing the JVM to utilize the entire heap by setting both the initial
and maximum sizes to 2 GB.
Finally, the last line of the table shows what happens when the heap is reasonably sized and
we set a realistic time ratio goal of 5%. The JVM itself determined that approximately 2 GB
was the optimal heap size, and it achieved the same throughput as the hand-tuned case.
1. Dynamic heap tuning is a good first step for heap sizing. For a wide set of applic-
ations, that will be all that is needed, and the dynamic settings will minimize the
JVM's memory use.
2. It is possible to statically size the heap to get the maximum possible performance.
The sizes the JVM determines for a reasonable set of performance goals are a
good first start for that tuning.