Skip to content

Instantly share code, notes, and snippets.

@sushanthmangalore
Created June 1, 2016 12:59
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sushanthmangalore/69871cbc87c97cbca67a130469fdee90 to your computer and use it in GitHub Desktop.
Save sushanthmangalore/69871cbc87c97cbca67a130469fdee90 to your computer and use it in GitHub Desktop.
JVM Flags
a. –XX:+UseParNewGC – Use parallel GC in the young generation
b. –XX:–UseParNewGC – Use serial GC in young generation
c. –XX:+UseParallelGC - Use parallel GC in the young generation, serial in old generation
d. –XX:+UseSerialGC – Use serial generational GC
e. –XX:+UseParallelOldGC – Use parallel GC in both young and old generation.
f. –XX:+UseConcMarkSweepGC – Use Concurrent Mark Sweep GC in old generation.
g. –XX:+AlwaysTenure – Always create objects in old generation.
h. –XX:+UseG1GC – Use G1 garbage collector
i. –XX:PretenureSizeThreshold=<n bytes> - Allocate objects greater than n bytes in size directly in old generation
j. –Xms=<nM/m/g/G> – This option lets you specify minimum memory that is allocated to your Java heap.
k. –Xmx=<nM/m/g/G> – This option lets you specify maximum memory that is allocated to your Java heap. Some JVMs include memory needed for internal structures (such as compiler threads, GC structures, code cache, and so on) in -Xmx value.
l. -XX:NewSize=<nM/m/g/G> – Minimum new generation size.
m. –XX:MaxNewSize=<nM/m/g/G> – Maximum new generation size
n. -XX:NewRatio – Controls the size of the young generation relative to the old generation. E.g. -XX:NewRatio=3 means that the ratio between the old and young generation is 1:3, the combined size of eden and the survivor spaces will be fourth of the heap.
o. -XX:SurvivorRatio=<n> - The SurvivorRatio parameter controls the size of the two survivor spaces. For example, -XX:SurvivorRatio=6 sets the ratio between each survivor space and eden to be 1:6, each survivor space will be one eighth of the young generation.
p. –verbosegc -Xloggc:"<path to log>"- Turns on verbose garbage collection output for the JVM and redirect verbose GC output to a file.
q. -XX:-DisableExplicitGC – By default calls to System.gc() are enabled (-XX:-DisableExplicitGC).-XX:+DisableExplicitGC disabled calls to System.gc().
r. -XX:LargePageSizeInBytes=<Nm/m> - Sets the large page size used for the Java heap.
s. -XX:-HeapDumpOnOutOfMemoryError - Dump heap to file when java.lang.OutOfMemoryError is thrown.
t. -XX:HeapDumpPath=./java_pid<pid>.hprof - Path to directory or filename for heap dump.
u. -XX:-PrintGCDetails - Print more details at garbage collection.
v. -XX:ParallelGCThreads=n - Sets the number of garbage collection threads in the young and old parallel garbage collectors.
w. -XX:InitialTenuringThreshold=n - The tenuring threshold is the number of times an object survives a young collection before being promoted to the old, or tenured, generation.
x. -XX:MaxTenuringThreshold=n - Sets the maximum tenuring threshold for use in adaptive GC sizing.
y. -XX:+UseTLAB - Use thread-local object allocation. Mainly benefits multiprocessor systems
z. ‐XX:TLABSize=<nk/K> – The size of each TLAB. Make sure the young generation is large enough to hold all the TLABs for each thread (try 64K, 128K, 256K)
aa. –XX:+ResizeTLAB – Dynamizally resize TLAB size for threads.
bb. –XX:PermSize:=<Nm/M> - Intial perm generation size
cc. -XX:MaxPermSize=<Nm/M> - Sets the max perm generation size.
dd. -XX:MaxMetaspaceSize=<nm/M/g/G/k/K> - Metaspace is the successor to PermGen. Introduced in Java 8. Default is unlimited. This space is used to store class metadata.
ee. -XX:+CMSParallelRemarkEnabled –Whether parallel remark is enabled (only if ParNewGC is set)
ff. -XX:CMSInitiatingOccupancyFraction - Percentage CMS generation occupancy to start a CMS collection cycle.
gg. -XX:+UseCMSInitiatingOccupancyOnly - Only use occupancy as a criterion for starting a CMS collection.
hh. -XX:+ScavengeBeforeFullGC - Instructs garbage collector to collect young generation before doing Full GC.
ii. -XX:+CMSScavengeBeforeRemark – Instructs garbage collector to attempt scavenge before the CMS remark step.
jj. -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=<n> -XX:GCLogFileSize=<nm/M> – Specify GC File rotation, number of log files and log file size.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment