Setting the heap size for most configurations
This section contains guidelines for determining the appropriate Java heap size for most configurations. For most production applications, the IBM JVM Java heap size defaults are too small and must be increased. In addition, if the –Xgcpolicy:gencon option is used, the nursery size must be increased.
There are several approaches to setting optimal heap sizes; we outline one useful approach here. Set the initial heap size (-Xms option) to a reasonable value (for example, 256 MB), and the maximum heap size (-Xmx) option to something reasonable, but large (for example, 1024 MB). The maximum heap size must never force the heap to page. It is imperative that the heap always stays in physical memory. The JVM then tries to keep the GC time within reasonable limits by growing and shrinking the heap. The output from verbosegc must then be used to monitor GC activity.
If Generational Concurrent GC is used (-Xgcpolicy:gencon), the new area size can also be set to specific values. By default, the new size is a quarter of the total heap size or 64 MB, whichever is smaller. To improve performance, the nursery size must be a quarter of the heap size or larger, and it must not be capped at 64MB. New area sizes are set by JVM options: -Xmn <size>, -Xmns<initialSize>, and -Xmnx<maxSize>.
After the initial heap sizes are set, verbosegc traces must then be used to monitor GC activity. After analyzing the output, modify the heap settings accordingly. For example, if the percentage of time in GC is high and the heap has grown to its maximum size, throughput can be improved by increasing the maximum heap size. As a rule of thumb, greater than 10% of the total time spent in GC is generally considered high.