Hotspot Jvm Options Cheat Sheet

ADVERTISEMENT

Java 8
HotSpot JVM options cheatsheet
Alexey Ragozin –
All concrete numbers in JVM options in this card are for illustrational purposes only!
Java Process Memory
Available combinations of garbage collection algorithms in HotSpot JVM
Young collector
Old collectior
JVM Flags
JVM Memory
Serial (DefNew)
Serial Mark Sweep Compact
-XX:+UseSerialGC
Java Heap
Non-Heap
Parallel scavenge (PSYoungGen)
Serial Mark Sweep Compact (PSOldGen)
-XX:+UseParallelGC
Young Gen
-XX:+UseParallelOldGC
Parallel scavenge (PSYoungGen)
Parallel Mark Sweep Compact (ParOldGen)
Parallel (ParNew)
Serial Mark Sweep Compact
-XX:+UseParNewGC
1
Serial (DefNew)
Concurrent Mark Sweep
-XX:-UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC -XX:+UseConcMarkSweepGC
Parallel (ParNew)
Concurrent Mark Sweep
Garbage First (G1)
-XX:+UseG1GC
-Xms/-Xmx
1 - Notice minus before UseParNewGC, which is explicitly disables parallel mode
GC log detail options
GC Log rotation
Memory sizing options
-Xloggc:<file>
-verbose:gc
or
-XX:+PrintGC
Print basic GC info
Redirects GC output to a file instead of console
-Xms256m or -XX:InitialHeapSize=256m
Initial size of JVM heap (young + old)
-XX:+PrintGCDetails
Print more details GC info
Enable GC log rotation
-XX:+UseGCLogFileRotation
-Xmx2g or -XX:MaxHeapSize=2g
-XX:+PrintGCTimeStamps
Print timestamps for each GC
Size threshold for GC log file
-XX:GCLogFileSize=512m
Max size of JVM heap (young + old)
event (seconds count from start of JVM)
Absolute (initial and max) size of
-XX:NewSize=64m
-XX:NumberOfGCLogFiles=5
Number GC log files
young space (Eden + 2 Survivours)
-XX:MaxNewSize=64m
-XX:+PrintGCDateStamps
Print date stamps at garbage
More logging options
collection events:
2011-09-08T14:20:29.557+0400: [GC...
-XX:NewRatio=3
Alternative way to specify size
-XX:+PrintTenuringDistribution
Print detailed
of young space. Sets ratio of young vs old space
demography of young space after each collection
-XX:+PrintReferenceGC
Print times for special
(e.g.
-XX:NewRatio=2
means that young space will be 2 time
smaller than old space, i.e. 1/3 of heap size).
(weak, JNI, etc) reference processing during STW pause
-XX:+PrintTLAB
Print TLAB allocation statistics
-XX:SurvivorRatio=15
Sets size of single survivor space
-XX:+PrintJNIGCStalls
Reports if GC is waiting for
relative to Eden space size
-XX:+PrintPLAB
Print survivor PLAB details
native code to unpin object in memory
(e.g.
means that each
-XX:NewSize=64m -XX:SurvivorRatio=6
Survivor space will be 8m and Eden will be 48m).
-XX:+PrintOldPLAB
Print old space PLAB details
-XX:+PrintGCCause
Add cause of GC in log
Initial and max size of
-XX:MetaspaceSize=512m
-XX:+PrintGCTaskTimeStamps
Print timestamps for
JVM’s metaspace space
-XX:MaxMetaspaceSize=1g
-XX:+PrintAdaptiveSizePolicy
individual GC worker thread tasks (very verbose)
Print young space sizing decisions
Thread stack size
-Xss256k (size in bytes) or
-XX:+PrintHeapAtGC
Print heap details on GC
-XX:ThreadStackSize=256 (size in Kbytes)
-XX:+PrintPromotionFailure
-XX:CompressedClassSpaceSize=1g
Memory reserved
Print additional information for promotion failure
-XX:+PrintHeapAtSIGBREAK
Print heap details on signal
for compressed class space (64bit only)
-XX:+PrintGCApplicationStoppedTime
-XX:+PrintClassHistogramAfterFullGC
Initial size and max
-XX:InitialCodeCacheSize=256m
Print summary after each JVM safepoint (including non-GC)
Prints class histogram after full GC
-XX:ReservedCodeCacheSize=512m
size of code cache area
-XX:+PrintGCApplicationConcurrentTime
-XX:+PrintClassHistogramBeforeFullGC
-XX:MaxDirectMemorySize=2g
Maximum amount
Print time for each concurrent phase of GC
Prints class histogram before full GC
of memory available for NIO off-heap byte buffers
- Highly recommended option
- Highly recommended option
Concurrent Mark Sweep (CMS)
Garbage First (G1)
Young space tenuring
-XX:InitialTenuringThreshold=8
CMS initiating options
Initial value for tenuring threshold (number of collections
-XX:+UseCMSInitiatingOccupancyOnly
-XX:G1HeapRegionSize=32m
Size of heap region
before object will be promoted to old space)
Only use predefined occupancy as only criterion for starting
-XX:G1ReservePercent=10
Percentage of heap to keep free.
-XX:MaxTenuringThreshold=15
a CMS collection (disable adaptive behaviour)
Reserved memory is used as last resort to avoid promotion failure.
Max value for tenuring threshold
-XX:CMSInitiatingOccupancyFraction=70
-XX:InitiatingHeapOccupancyPercent=45
Percentage CMS generation occupancy to start a CMS cycle.
Max object size
-XX:PretenureSizeThreshold=2m
Percentage of (entire) heap occupancy to trigger concurrent GC
A negative value means that
is used.
allowed to be allocated in young space (large objects will be
CMSTriggerRatio
allocated directly in old space). Thread local allocation
-XX:G1MixedGCCountTarget=8
Target number of mixed
-XX:CMSBootstrapOccupancy=50
bypasses this check, so if TLAB is large enough object
collections after a marking cycle
Percentage CMS generation occupancy at which to initiate
exciding size threshold still may be allocated in young space.
CMS collection for bootstrapping collection stats.
-XX:G1HeapWastePercent=10
If garbage level is below
-XX:+AlwaysTenure
Promote all objects surviving
-XX:CMSTriggerRatio=70
threshold, G1 will not attempt to reclaim memory further
young collection immediately to tenured space
Percentage of MinHeapFreeRatio in CMS generation that is
-XX:G1ConfidencePercent=50
Confidence level
(equivalent of
-XX:MaxTenuringThreshold=0
)
allocated before a CMS collection cycle commences.
for MMU/pause prediction
-XX:+NeverTenure
Objects from young space
-XX:CMSTriggerInterval=60000
Periodically
triggers_
-XX:MaxGCPauseMillis=500
Target GC pause duration.
will never get promoted to tenured space unless survivor
CMS collection. Useful for deterministic object finalization.
G1 is not deterministic, so no guaranties for GC pause to satisfy this limit.
space is not enough to keep them
CMS Stop-the-World pauses tuning
Thread local allocation
CMS Diagnostic options
-XX:CMSWaitDuration=30000
-XX:+UseTLAB
Use thread local allocation blocks in eden
-XX:PrintCMSStatistics=1
Once CMS collection is triggered, it will wait for next young
Print additional CMS statistics. Very verbose if n=2.
collection to perform initial mark right after. This parameter
-XX:+ResizeTLAB
Let JVM resize TLABs per thread
specifies how long CMS can wait for young collection
-XX:+PrintCMSInitiationStatistics
-XX:TLABSize=1m
Initial size of thread’s TLAB
Print CMS initiation details
-XX:+CMSScavengeBeforeRemark
-XX:MinTLABSize=64k
Min size of TLAB
Force young collection before remark phase
-XX:+CMSDumpAtPromotionFailure
Parallel processing
Dump useful information about the state of the CMS old
-XX:+CMSScheduleRemarkEdenSizeThreshold
generation upon a promotion failure
-XX:ConcGCThreads=2
If
den used is below this value, don't try to schedule remark
E
Number of parallel threads used for concurrent phase.
-XX:+CMSPrintChunksInDump
(with optin above)
-XX:CMSScheduleRemarkEdenPenetration=20
Add more detailed information about the free chunks
-XX:ParallelGCThreads=16
Eden occupancy
at which to try and schedule remark pause
%
Number of parallel threads used for stop-the-world phases.
-XX:+CMSPrintObjectsInDump
(with optin above)
-XX:CMSScheduleRemarkSamplingRatio=4
Add more detailed information about the allocated objects
-XX:+ParallelRefProcEnabled
Enable parallel
Start sampling Eden top at least before young generation occupancy
processing of references during GC pause
reaches 1/ of the size at which we plan to schedule remark
Misc CMS options
CMS Concurrency options
-XX:+DisableExplicitGC
-XX:+CMSClassUnloadingEnabled
JVM will ignore application calls to
System.gc()
If not enabled, CMS will not clean permanent space. You
-XX:+CMSParallelInitialMarkEnabled
may need to enable it for containers such as JEE or OSGi.
-XX:+ExplicitGCInvokesConcurrent
Whether parallel initial mark is enabled (enabled by default)
Let
trigger concurrent collection instead of full GC
System.gc()
-XX:+CMSIncrementalMode
-XX:+CMSParallelRemarkEnabled
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses
Enable incremental CMS mode. Incremental mode was meant for
Whether parallel remark is enabled (enabled by default)
Same as above but also triggers permanent space collection.
severs with small number of CPU, but may be used on multicore
-XX:+CMSParallelSurvivorRemarkEnabled
servers to benefit from more conservative initiation strategy.
-XX:SoftRefLRUPolicyMSPerMB=1000
Factor
Whether parallel remark of survivor space enabled,
for calculating soft reference TTL based on free heap size
-XX:+CMSOldPLABMin=16 -XX:+CMSOldPLABMax=1024
effective only with option above (enabled by default)
Min and max size of CMS gen PLAB caches per worker per block size
Command to be executed
-XX:OnOutOfMemoryError=…
in case of out of memory.
-XX:+CMSConcurrentMTEnabled
E.g. “kill -9 %p” on Unix or “taskkill /F /PID %p” on Windows.
Use multiple threads for concurrent phases.
- Options for “deterministic” CMS, they disable some heuristics and
require careful validation

ADVERTISEMENT

00 votes

Related Articles

Related forms

Related Categories

Parent category: Education
Go