■
Decide the total amount of memory you can aord for the JVM. Accordingly, graph your
own performance metric against young generation sizes to nd the best setting.
■
Make plenty of memory available to the young generation. The default is calculated from
NewRatio and the -Xmx setting.
■
Larger eden or younger generation spaces increase the spacing between full GCs. But young
space collections could take a proportionally longer time. In general, keep the eden size
between one fourth and one third the maximum heap size. The old generation must be
larger than the new generation.
For up-to-date defaults, see
Java HotSpot VM Options.
EXAMPLE 4–1 Heap Conguration onSolaris
This is an exmple heap conguration used by Enterprise Server on Solaris for large applications:
-Xms3584m
-Xmx3584m
-verbose:gc
-Dsun.rmi.dgc.client.gcInterval=3600000
Survivor Ratio Sizing
The SurvivorRatio parameter controls the size of the two survivor spaces. For example,
-XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6, each
survivor space will be one eighth of the young generation. The default for Solaris is 32. If
survivor spaces are too small, copying collection overows directly into the old generation. If
survivor spaces are too large, they will be empty. At each GC, the JVM determines the number
of times an object can be copied before it is tenured, called the tenure threshold. This threshold
is chosen to keep the survivor space half full.
Use the option -XX:+PrintTenuringDistribution to show the threshold and ages of the
objects in the new generation. It is useful for observing the lifetime distribution of an
application.
Rebasing DLLs on Windows
When the JVM initializes, it tries to allocate its heap using the -Xms setting. The base addresses
of Application Server DLLs can restrict the amount of contiguous address space available,
causing JVM initialization to fail. The amount of contiguous address space available for Java
memory varies depending on the base addresses assigned to the DLLs. You can increase the
amount of contiguous address space available by rebasing the Application Server DLLs.
ManagingMemoryandGarbage Collection
Chapter4 • TuningtheJavaRuntimeSystem 89