Some of the most commonly used JVM Heap tuning flags are mentioned below.
Heap size
Ø Initial Heap size: -Xms e.g. -Xms2048m
Ø Maximum
Heap size: -Xmx e.g. -Xmx2048m
Ø To
set ratio of young generation to old generation: -XX:NewRatio
Ø To
set initial size of the young generation: -XX:NewSize
Ø To
set Maximum size of the young generation: -XX:MaxNewSize
Ø To
set permgen space initial size:
-XX:PermSize=N
(JDK 7 only) OR -XX:MetaspaceSize=N
(JDK 8 only)
Ø To set maximum size of Permgen space:
-XX:MaxPermSize=N
(JDK 7 only) OR -XX:MaxMetaspaceSize=N
(JDK 8 only)
Ø Instruct
to take heap dump on out of memory error: -XX:+HeapDumpOnOutOfMemoryError
Ø To
specify path for Heap dump file: -XX:HeapDumpPath=<path>
Garbage Collection
Ø To instruct use of Serial Garbage
collector: -XX:+UseSerialGC
Ø To instruct use of parallel Garbage
collector: -XX:+UseParallelGC
Ø To instruct use of Concurrent Mark
& Sweep collector:
-XX:+UseConcMarkSweepGC
-XX:+UseParNewGC
Ø To instruct use of G1 GC collector: -XX:+UseG1GC
Ø To set no of threads (in case of
parallel GC): -XX:ParallelGCThreads=N
Ø To enable GC logging: -verbose:gc
Ø To specify separate log file name for
GC log instead of standard output:
-Xloggc:<path>
Ø To enabled detailed GC logging: -XX:+PrintGCDetails
Ø To print relative timestamp for each GC
event: -XX:+PrintGCTimeStamps
Ø To set the amount of the young
generation set aside for survivor spaces: -XX:InitialSurvivorRatio=N
o
survivor_space_size
= new_size / (initial_survivor_ratio + 2)
o
For
the default initial survivor ratio of 8, each survivor space will occupy 10% of
the young generation.
Ø To specify initial number of GC
cycles the JVM attempts to keep an object in the survivor spaces: -XX:InitialTenuringThreshold=N
o
The
default is 7 for the throughput and G1 collectors, and 6 for CMS.JVM may change
this value on his own.
Ø To specify maximum number of GC cycles the JVM attempts to keep an
object in the survivor spaces:
o
-XX:MaxTenuringThreshold=N
o
For
the throughput and G1 collectors, the default maximum threshold is 15, and for
CMS it is 6.
CMS & G1 specific
Ø To specify when CMS/G1 should begin background
scanning of the old generation: -XX:CMSInitiatingOccupancyFraction=N
Can try to reduce
this value if there are concurrent mode failures.
Ø To
set the number of threads to use for CMS/G1 background scanning: -XX:ConcGCThreads=N
No comments:
Post a Comment