Professional Documents
Culture Documents
In this article I have collected a list of options related to GC tuning in JVM. This is not a comprehensive list,
I have collected only options which I use in practice (or at least understand why I may want to use them).
Compared to previous version a few useful diagnostic options were added. Additionally section for G1
specific options was introduced.
HotSpot GC collectors
HotSpot JVM may use one of 6 combinations of garbage collection algorithms listed below.
Young collector
Old collector
JVM option
Serial (DefNew)
Parallel scavenge (PSYoungGen)
Parallel scavenge (PSYoungGen)
Parallel (ParNew_
Serial (DefNew)
Serial Mark-Sweep-Compact
Serial Mark-Sweep-Compact (PSOldGen)
Parallel Mark-Sweep-Compact (ParOldGen)
Serial Mark-Sweep-Compact
Concurrent Mark Sweep
Parallel (ParNew)
-XX:+UseSerialGC
-XX:+UseParallelGC
-XX:+UseParallelOldGC
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:-UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
-XX:+UseG1GC
G1
GC logging options
Please note that many of logging options could be modified on running JVM using JMX (e.g. via JConsole).
JVM option
General options
Description
-verbose:gc or -XX:+PrintGC
-XX:+PrintGCDetails
-XX:+PrintGCTimeStamps
-XX:+PrintGCDateStamps
-XX:+PrintGCTaskTimeStamps
-Xloggc:<file>
-XX:+PrintTenuringDistribution
-XX:+PrintTLAB
-XX:+PrintReferenceGC
-XX:+PrintJNIGCStalls
-XX:+PrintGCApplicationStoppedTime
Page 1
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintClassHistogramAfterFullGC
-XX:+PrintClassHistogramBeforeFullGC
-XX:+HeapDumpAfterFullGC
-XX:+HeapDumpBeforeFullGC
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=<path>
pause
Print time for each concurrent phase of GC
Prints class histogram after full GC
Prints class histogram before full GC
Creates heap dump file after full GC
Creates heap dump file before full GC
Creates heap dump in out-of-memory condition
Specifies path to save heap dumps
-XX:SurvivorRatio=<ratio>
-XX:PermSize=<size> -XX:MaxPermSize=<size>
-Xss256k (size in bytes) or
-XX:ThreadStackSize=256 (size in Kbytes)
-XX:MaxDirectMemorySize=<value>
Page 2
Description
Initial and max size of heap space (young
space + tenured space). Permanent space
does not count to this size.
Initial and max size of young space.
Alternative way to specify young space size.
Sets ration of young vs tenured space (e.g. XX:NewRatio=2 means that young space will
be 2 time smaller than tenuted space).
Sets size of single survivor space as a portion
of Eden space size (e.g. -XX:NewSize=64m XX:SurvivorRatio=6 means that each survivor
space will be 8m and eden will be 48m).
Initial and max size of permanent space.
Sets size of stack area dedicated to each
thread. Thread stacks do not count to heap
size.
Maximum size of off-heap memory available
for JVM
-XX:PretenureSizeThreshold=<size>
-XX:+AlwaysTenure
-XX:+NeverTenure
Description
Initial value for tenuring threshold (number of
collections before object will be promoted to
tenured space).
Max value for tenuring threshold.
Max object size allowed to be allocated in
young space (large objects will be allocated
directly in old space). Thread local allocation
bypasses this check so if TLAB is large enough
object exciding size threshold still may be
allocated in young.
Promote all objects surviving young collection
immediately to tenured space (equivalent of XX:MaxTenuringThreshold=0)
Objects from young space will never get
promoted to tenured space while survivor
space is large enough to keep them.
Description
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=<n>
-XX:CMSBootstrapOccupancy=<n>
-XX:CMSTriggerRatio=<n>
-XX:CMSTriggerPermRatio=<n>
-XX:CMSWaitDuration=<timeout>
Page 3
-XX:+CMSScavengeBeforeRemark
-XX:+CMSScheduleRemarkEdenSizeThreshold
-XX:CMSScheduleRemarkEdenPenetration=<n>
-XX:CMSScheduleRemarkSamplingRatio=<n>
-XX:CMSRemarkVerifyVariant=1
Parallel execution
-XX:+UseParNewGC
-XX:+CMSConcurrentMTEnabled
-XX:ConcGCThreads=<n>
-XX:ParallelGCThreads=<n>
Miscellaneous options
-XX:+CMSClassUnloadingEnabled
Miscellaneous GC options
JVM option
-XX:+DisableExplicitGC
-XX:SoftRefLRUPolicyMSPerMB=1000
Description
JVM will ignore application calls to System.gc()
Soft references time to live in milliseconds per
MB of free space in the heap
OutOfMemoryError conditions
-XX:+UseGCOverheadLimit
Page 4
-XX:GCTimeLimit=98
-XX:GCHeapFreeLimit=2
Page 5
Description
Size of heap region for G1 collector. Region size could be
from 1MiB to 32MiB. Default is initial heap size / 2048.
Confidence coefficient for G1 pause prediction heuristics
It determines the minimum reserve we should have in the
heap to minimize the probability of promotion failure
GC time per MMU time slice in milliseconds (for G1 only)
Time slice for MMU specification in milliseconds (for G1
only). Should be greater than parameter above.