JVM flags
The following are the JVM parameters/flags commonly used in applications to tune the JVM for better performance. Tuning values depend on our application's behavior and the rate at which it is generated. So there is no defined guideline to use specific values for JVM flags in order to achieve better performance.
-Xms and -Xmx
The -Xms
and -Xmx
are known as the minimum and maximum heap size. Setting -Xms
equal to -Xmx
prevents GC pauses during heap expansion and improves performance.
-XX:NewSize and -XX:MaxNewSize
We can set the size of the Young Generation using -XX:MaxNewSize
. The Young Generation resides under the total heap memory and the Old Generation size will be smaller if we set the size of the Young Generation as large. The Young Generation size should never be larger than the Old Generation for stability reasons. Thus, -Xmx/2
is the maximum size we can set for -XX:MaxNewSize
.
To achieve better performance, set the initial size of the Young Generation by setting the -XX:NewSize...