Java garbage collector tuning for application performance

NSJ incorporates the HotSpot VM. This section discusses the options available for tuning the JVM, suggests flags and values to tune the Java HotSpot VM, and points to the HotSpot tuning information on the Internet. GC tuning is assisted by GC profile data which can be collected and analyzed as explained in the subsequent sections.

Since GC occurs when generations fill up, the amount of available total heap memory has direct impact on the performance. The parameters that affect the heap are as follows:

-Xms

The startup size of memory allocation pool (the Java heap).

-Xmx

The maximum memory allocation pool.

When using NSJ 11, the theoretical maximum value is 484 GB. However, the actual limit is constrained by the size of physical memory and swap space available from the Kernel-managed swap space, and the number of processes contending for these resources. For more information, see Java heap size with NSJ 11.

For larger server applications, the default values of the two options listed are usually inadequate. In general, you must assign as much memory to the JVM. Another important factor that affects performance is the proportion of the heap that is assigned to the young generation. The parameters for the young generation heap are as follows:

-XX:NewRatio=nn

The ratio between the young and old.

-XX:NewSize=nn

The lower size bound.

-XX:MaxNewSize=nn

The upper size bound.

-XX:SurvivorRatio=nn

Tune the survivor spaces.

For example,

java -Xms512m -Xmx512m -XX:NewSize=256m -XX:MaxNewSize=256m \ -XX:SurvivorRatio=2 <class>

These options notify the JVM to set:
  • The initial size of the heap to 512 MB.

  • The maximum heap size to 512 MB.

  • The new generation to 256 MB (128 MB belongs to Eden and 2x64 MB survivor).

  • The old generation to 256 MB.

For more information about all these parameters, see Java HotSpot VM Options.

For more information about tuning garbage collection with the Java SE 8 HotSpot virtual machine, and for general performance tuning information, see the following documentation:

NOTE:

The following options do not apply for NonStop system:

-XX:-UseBoundThreads
-XX:+UseAltSigs
-XX:+AllowUserSignalHandlers
-XX:+MaxFDLimit
-XX:-UseLWPSynchronization
-XX:PreBlockSpin=nn
-XX:-UseMPSS
-XX:+UseSpinning