Each running Java program has an associated heap. If the sum of
all of the Java heap sizes and all other usages of virtual memory
exceeds the size of physical memory, then the heap page, causing
performance to degrade. To minimize the paging, use the following
guidelines:
- For a trial run, activate verbosegc for each running
JVM.
- Based on the verbosegc output, set the initial heap
size to a relatively low value. For example, assume that the
verbosegc report shows that the heap size grows quickly to
32 MB, then grows more slowly to 40 MB. Based on this, set the
initial heap size to 32 MB (-Xms32m).
- Based on the verbosegc output, set the maximum heap
size large enough to allow for peak throughput. In the previous
example, a maximum heap size of 64 MB may be appropriate
(-Xmx64m).
- Do not set the heap sizes too low, so that garbage collections
do not occur too often but large enough to avoid paging.
