How to Tune Java Garbage Collection
This is an excelent and very clear article on Java JVM tuning.
Think about the fundamental cause of GC tuning. The Garbage Collector clears an object created in Java. The number of objects necessary to be cleared by the garbage collector as well as the number of GCs to be executed depend on the number of objects which have been created. Therefore, to control the GC performed by your system, you should, first, decrease the number of objects created.
The following table shows options related to memory size among the GC options that can affect performance.
Table 1: JVM Options to Be Checked for GC Tuning.
Classification Option Description Heap area size -Xms
Heap area size when starting JVM -Xmx
Maximum heap area size New area size -XX:NewRatio
Ratio of New area and Old area -XX:NewSize
New area size -XX:SurvivorRatio
Ratio of Eden area and Survivor area
I frequently use-Xms
,-Xmx
, and-XX:NewRatio
options for GC tuning.-Xms
and-Xmx
option are particularly required. How you set theNewRatio
option makes a significant difference on GC performance.Some people ask how to set the Perm area size? You can set the Perm area size with the-XX:PermSize
and-XX:MaxPermSize
options but only whenOutOfMemoryError
occurs and the cause is the Perm area size.
The full article can be founs at : http://www.cubrid.org/blog/dev-platform/how-to-tune-java-garbage-collection/