The JVM provides a number of parameters that can be configured to tune the JVM, log GC logs, and so on. This chapter lists only the parameters THAT I have used and learned about myself, broken down by function.
Memory related
These parameters allow you to adjust the MEMORY allocation of the JVM
Xms Initial heap size(in bytes) -xMS2G or -xx :InitialHeapSize= 2048M
Maximum heap size(in bytes) -xmx2g or -xx :MaxHeapSize=2048m
Maximum new generation size(in bytes) -xmn512m or -xx :MaxNewSize= 512M
Initial size of permanent generation(in bytes) -xx :PermSize= 128M
MaxPermSize(deprecated after JDK1.8); Maximum size of permanent generation(in bytes)
Initial size of MetaspaceSize(in bytes) -xx :MetaspaceSize= 128MB
MaxMetaspaceSize(JDK1.8 used to replace MaxPermSize); Maximum size of Metaspaces (in bytes); -XX:MaxMetaspaceSize=256m
ThreadStackSize (in Kbytes) -xss256k or -xx :ThreadStackSize=256k
MaxDirectMemorySize Maximum total size of NIO direct-buffer allocations, Maximum direct memory (off-heap) size -XX:MaxDirectMemorySize=256m
GC policy correlation
These parameters allow you to tune THE GC performance of the JVM
英文解释 : the ratio of SurvivorRatio to the Eden /survivor space =6 If set to 6, it means that the ratio of each survivor zone to Eden zone is 1:6, and each survivor zone accounts for 1/8 of the new generation
PretenureSizeThreshold = Maximum size in bytes of objects allocated in DefNew generation; Zero means no maximum Chinese explanation: can directly in Cenozoic allocation objects of maximum value, 0 means no maximum Method of use: – XX: PretenureSizeThreshold = 1000000 experience with: Set this parameter to allocate objects larger than this value directly in the old age, avoiding massive memory replication in the Eden and Survivor regions. This parameter is only valid to the Serial and ParNew collectors, and the Parallel Avenge avenge is not known
MaxTenuringThreshold Maximum value fo tenuring threshold -xx :MaxTenuringThreshold=10 After each Minor GC, the age of each object increases by 1, and when this value is exceeded, the age is old, up to 15
Use the Serial garbage collector -xx :+UseSerialGC -xx :+UseSerialGC Not recommended, poor performance, older generations will use the SerialOld garbage collector
-xx :+UseParNewGC -xx :+UseParNewGC -xx :+UseParNewGC
ParallelGCThreads -xx :ParallelGCThreads=16 ParallelGCThreads -xx :ParallelGCThreads=16
Use the Parallel Scavenge collector the insane garbage collector. -xx :+UseParallelGC -xx :+UseParallelGC -xx :+UseParallelGC
UseParallelOldGC Use the ParallelOld garbage collector the Avenge. Enable -xx :+UseParallelOldGC
英文解释 : Use Concurrent mark-sweep GC in the old generation Usage: Enable -xx :+UseConcMarkSweepGC Usage Experience: The younger generation will use the ParNew collector
CMSInitiatingOccupancyFraction English explanation: Percentage CMS generation occupancy to start a CMS collection cycle. A negative value means that CMSTriggerRatio is used Chinese explanation: the trigger execution CMS recovery area the percentage of memory footprint, current s negative said use CMSTriggerRatio set the value of the method of use: – XX: CMSInitiatingOccupancyFraction = 75 experience with: This parameter should be used with UseCMSInitiatingOccupancyOnly together
UseCMSInitiatingOccupancyOnly English explanation: Only use occupancy as a criterion for Chinese interpretation of staring a CMS collection: Only according to the occupancy as a start of CMS collecting standard, the default closed method of use: open – XX: + UseCMSInitiatingOccupancyOnly
UseCMSCompactAtFullCollection English explanation: Use Mark – Sweep – Compact algorithm at full Chinese interpretation of the collections: Use the CMS to compression of memory, when performing a Full GC off by default to use: open – XX: + UseCMSCompactAtFullCollection
CMSFullGCsBeforeCompaction English explanation: the Number of CMS full collection done before a compaction if > 0 Chinese explanation: how many times after FGC memory compression Method of use: -XX:CMSFullGCsBeforeCompaction=1
Whether class unloading is enabled when using CMS GC CMSClassUnloadingEnabled Whether class unloading is disabled when using CMS GC Open – XX: + CMSClassUnloadingEnabled
Cmsparallelenabled Whether Parallel remark Enabled (only if ParNewGC), the cmSPARallelenabled remark enabled (ParNewGC only). Open – XX: + CMSParallelRemarkEnabled
英文解 决 : Use the garbage-first Garbage collector to Use the G1 Garbage collector to enable -xx :+UseG1GC
MaxGCPauseMillis Adaptive size policy maximum GC pause time goal in millisecond, 英 文 原 文 : The maximum GC time per MMU time slice, in milliseconds, or (G1 Only) the maximum GC time per MMU time slice. -XX:MaxGCPauseMillis=200
Ignore calls to system.gc () Ignore calls to system.gc () Enable -xx :+DisableExplicitGC PS: It is not recommended to enable this parameter. If this parameter is enabled, out-of-heap memory may fail to be reclaimed in a timely manner, resulting in memory overflow
GC log correlation
These parameters allow you to configure the JVM’s GC log output for easy analysis
Chinese definition of Xloggc English explanation: the GC log file: the GC log file path Method of use: – Xloggc: / data/gclog/gc log
UseGCLogFileRotation: Rotate gclog files(for long running applications). It requires -Xloggc:
To scroll GC log files, Xloggc must be configured
Number of gclog files in rotation(default:0,no rotation) -XX:NumberOfGCLogFiles=4
GCLogFileSize GC log file size,requires UseGCLogFileRotation. Set to 0 to only trigger rotation via JCMD UseGCLogFileRotation (0) indicates that only the JCMD command is used to trigger GC file rotation. Run the following command: -xx :GCLogFileSize= 100K
PrintGCDetails Print more details at garbage collection Open – XX: + PrintGCDetails can through the jinfo – flag [+ | -] PrintGCDetails < pid > or jinfo – flag PrintGCDetails = < value > < pid > to dynamic open or set values
PrintGCDateStamps Print date stamps at garbage collection. This function is disabled by default. Open – XX: + PrintGCDateStamps can through the jinfo – flag [+ | -] PrintGCDateStamps < pid > or jinfo – flag PrintGCDateStamps = < value > < pid > To dynamically turn on or set values
PrintTenuringDistribution English explanation: Print tenuring age Chinese definition of information: Print for instance information age, the default closure method of use: Open – XX: + PrintTenuringDistribution
PrintGCApplicationStoppedTime English explanation: Print the time of application has had stopped Chinese explanation: Print application pause time, off by default to use: Open – XX: + PrintGCApplicationStoppedTime
PrintHeapAtGC: Print heap layout before and after each GC: Print heap layout before and after each GC
Abnormal related
These parameters allow you to perform certain operations in the event of a JVM exception to preserve the field for analysis
HeapDumpOnOutOfMemoryError English explanation: Dump heap to file the when Java lang. Interpretation OutOfMemoryError is thrown in Chinese: Export heap information to specified file when throwing memory overflow error. Open – XX: + HeapDumpOnOutOfMemoryError can through the jinfo – flag [+ | -] HeapDumpOnOutOfMemoryError < pid > or jinfo – flag HeapDumpOnOutOfMemoryError = < value > < pid > to dynamic open or set values
HeapDumpPath When HeapDumpOnOutOfMemoryError is on, The path(filename or directory) of the dump file(defaults to java_pid
Problem location and optimization related
These parameters can be used to optimize JVM performance or troubleshoot problems
英文解释 : use the server mode. Use method: -server
Tiered compilation enables tiered compilation -xx :+TieredCompilation closed -xx: -tieredcompilation is enabled by default in Java 1.8
NativeMemoryTracking Native memory tracking options Enabling details -xx :NativeMemoryTracking=detail Enabling summary -xx :NativeMemoryTracking= Summary Experience: Enabling this function increases performance consumption by 5%-10%
UnlockDiagnosticVMOptions English explanation: Enable normal processing of flags Chinese explanation: diagnosis to unlock the JVM option parameters, the default closure method of use: Open – XX: + UnlockDiagnosticVMOptions
PrintNMTStatistics Print native memory tracking summary data if it is on -xx :+PrintNMTStatistics -xx :+PrintNMTStatistics -xx :+PrintNMTStatistics Must fit parameters – XX: + UnlockDiagnosticVMOptions use, and can only be added in later
英文解 析 : Use adaptive generation sizing policies Enable -xx :+UseAdaptiveSizePolicy Disabled -xx: -useadaptivesizePolicy 1.7 This parameter is enabled by default. If the CMS reclaim algorithm is used, this parameter is disabled. After this parameter is enabled, the SurvivorRatio parameter becomes invalid