JVM tuning is an ever-evolving process that has changed with each version of Java. Since the release 5.0 of the J2SE, the JVM is able to provide some default configuration (Ergonomics), which is consistent with your environment. However, the smarter choice provided by Ergonomics is not always the optimal and without an explicit user setting, the performance can fall below your expectations.
Basically, the JVM tuning process can be divided into three steps:
Choose a correct JVM heap size. This can be divided into setting an appropriate initial heap size (
-Xms
) and a maximum heap size (-Xmx
).Choose an initial heap size equal to maximum heap size for production environment. For development environment set up the initial heap size to about half the maximum size.
Don't exceed the 2GB limit for a single application server instance or the garbage collector performance might become a bottleneck.
Choose a correct ratio between young generations (where objects are initially placed after instantiation...