Equivalent to -XX:InitialHeapSize, set the JVM initial heap memory to 512M
-Xmx2048m
Equivalent to -XX:MaxHeapSize, set the JVM maximum heap memory to 2048M
-Xss256k
Equivalent to -XX:ThreadStackSize, set the Java thread stack size
-Xmn
Set the space size of the new generation, generally not configured
-XX:-UseAdaptiveSizePolicy
Disable adaptive memory allocation strategy
method area
JDK7
-XX:PermSize=100m
-XX:MaxPermSize=100m
JDK8
-XX:MetaspaceSize=100m
-XX:MaxMetaspaceSize=100m
Scale settings
-XX:SurvivorRatio=8
Set the ratio of the Eden area to the Survivor area in the new generation. The default value is 8, that is, Eden:so:s1=8:1:1
-XX:NewRatio=2
Set the ratio of the young generation to the old generation, the default value is 2
Size description
Generally, -Xms and -Xmx are configured to the same value, in order to improve the performance without re-dividing the calculation heap size after the Java garbage collection mechanism cleans up the heap area.
By default, initial heap size: 1/64 of physical memory size. Maximum heap size: 1/4 or 1G of physical memory size. Refer to the official documentation: https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gc-ergonomics.html
#示例:
Xms60m -Xmx60m -Xss512k
Adaptive Description
Note: 1) The default SurvivorRatio=8, but during the running process, the JVM may be dynamically adjusted, even if the adaptive parameter (-XX:-UseAdaptiveSizePolicy) is turned off, it will be dynamically adjusted. The solution is to explicitly specify -XX:SurvivorRatio= 8. 2) -Xmn can set the size of the space of the new generation to conflict with the NewRatio parameter. If -Xmn is set, it shall prevail.
2) Output GC log
Function
parameter
illustrate
output GC log
-verbose:gc
Print GC brief information
‐XX:+PrintGC
output GC log
‐XX:+PrintGCDetails
Output detailed log of GC
‐XX:+PrintGCTimeStamps
Output timestamp of GC (in the form of base time)
‐XX:+PrintGCDateStamps
Output the timestamp of the GC (in the form of a date, such as 2013‐05‐04T21:53:59.234+0800)
When this parameter is turned on, the new generation and the old generation are serial, the default in Client mode
New generation ParNew garbage collector
‐XX:+UseParNewGC
The new generation uses the ParNew collector, the old generation uses the serial collector, and the old generation can be used with CMS
-XX:ParallelGCThreads=10
The number of parallel threads in the new generation
Old age CMS garbage collector (low latency)
-XX:+UseConcMarkSweepGC
The old age uses the CMS garbage collector, which can only be used with Serial and ParNew, but not with Parallel. When CMS is enabled under JDK8, the new generation uses the ParNew collector by default.
-XX:CMSInitiatingOccupancyFraction=-1
Set the threshold value of heap memory usage, and start recycling when the threshold value is reached
-XX:+UseCMSCompactAtFullCollection
It is used to specify that the memory space is compressed after performing Full GC to avoid memory fragmentation. However, the memory compaction process cannot be executed concurrently, so the pause time becomes longer.
-XX:CMSFullGCsBeforeCompaction=0
Set how many times to perform Full GC to compact the memory space.
Sets the Java heap occupancy threshold that triggers the marking cycle. The default occupancy is 45% of the entire Java heap.
Performance parameters
-XX:MaxTenuringThreshold
The number of times to enter the retirement area, the default is 15
-XX:+DisableExplicitGC
Disable System.gc()
5) Other parameters
Function
parameter
illustrate
compiler mode
-Xint
Execute programs entirely in interpreter mode
-Xcomp
Fully adopted Even if the compiler executes the program, if there is a problem with the just-in-time compilation, the interpreted compilation will intervene in the execution
-Xmixed
Use the mixed mode of the interpreter + the compiler to execute the program together
TLAB
-XX:+UseTLAB
Enable TLAB, enabled by default
-XX:TLABWasteTargetPercent=1
TLAB accounts for 1% of the Eden area by default
default parameters
-XX:+PrintFlagsInitial
View default initial values for all parameters
-XX:+PrintFlagsFinal
View final values of all parameters
other
-XX:+DoEscapeAnalysis
Escape analysis, enabled by default
-XX:+EliminateAllocations
Scalar replacement, enabled by default
-XX:CompileThreshold=10000
JIT compilation method counter, default is 1500 in client mode and 10000 in server mode
-XX:+PrintCommandLineFlags
print command line arguments (including garbage collector)