Cao Yi

JVM Options of JDK 11

Index

2023-06-15

There are three main types of JVM options.

(Copy from here).

If you apply an advanced option, you always precede the option with -XX:. Similarly if you’re using a non-standard option, you’ll use -X. Standard options don’t prepend anything to the option. Ref

Full list JVM options of JDK11: English, Simplified Chinese

Example

# ps -ef | grep java
tomcat       520       1  2 Jun06 ?        00:02:21 /usr/lib/jvm/temurin-jdk/bin/java -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djdk.tls.ephemeralDHKeySize=2048 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 -server -Xms512m -Xmx1536m -XX:+UseG1GC -verbose:gc -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true -Djava.net.preferIPv4Stack=true -Dcom.sun.management.config.file=/usr/lib/jvm/temurin-jdk/jre/lib/management/management.properties -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false -Dorg.jboss.logging.provider=jdk -Dlog4j2.is.webapp=true -Dlog4j2.garbagefreeThreadContextMap=true -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/usr/local/tomcat/logs/heapdump.hprof -XX:MinHeapFreeRatio=10 -XX:MaxHeapFreeRatio=20 -Djava.locale.providers=JRE,SPI -Dignore.endorsed.dirs= -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar -Dcatalina.base=/usr/local/tomcat -Dcatalina.home=/usr/local/tomcat -Djava.io.tmpdir=/usr/local/tomcat/temp org.apache.catalina.startup.Bootstrap start
root        7273    6247  0 01:27 pts/0    00:00:00 grep --color=auto java

Tidy the JVM options as follows:

 -Djava.util.logging.config.file=/usr/local/tomcat/conf/logging.properties 
 -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager 
 -Djdk.tls.ephemeralDHKeySize=2048 
 -Djava.protocol.handler.pkgs=org.apache.catalina.webresources 
 -Dorg.apache.catalina.security.SecurityListener.UMASK=0027 
 -server 
 -Xms512m 
 -Xmx1536m 
 -XX:+UseG1GC 
 -verbose:gc 
 -Dorg.apache.el.parser.SKIP_IDENTIFIER_CHECK=true 
 -Djava.net.preferIPv4Stack=true 
 -Dcom.sun.management.config.file=/usr/lib/jvm/temurin-jdk/jre/lib/management/management.properties 
 -Dorg.apache.jasper.compiler.Parser.STRICT_QUOTE_ESCAPING=false 
 -Dorg.jboss.logging.provider=jdk 
 -Dlog4j2.is.webapp=true 
 -Dlog4j2.garbagefreeThreadContextMap=true 
 -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector 
 -XX:+HeapDumpOnOutOfMemoryError 
 -XX:HeapDumpPath=/usr/local/tomcat/logs/heapdump.hprof 
 -XX:MinHeapFreeRatio=10 
 -XX:MaxHeapFreeRatio=20 
 -Djava.locale.providers=JRE,SPI 
 -Dignore.endorsed.dirs= 
 -classpath /usr/local/tomcat/bin/bootstrap.jar:/usr/local/tomcat/bin/tomcat-juli.jar 
 -Dcatalina.base=/usr/local/tomcat 
 -Dcatalina.home=/usr/local/tomcat 
 -Djava.io.tmpdir=/usr/local/tomcat/temp

Some Changes from JDK 9 to JDK 11

-XX:+UseG1GC can be removed when using Java 11

Starting from Java 9, the default garbage collector (GC) was changed from Parallel GC to G1 (see JEP 248). Ref

Another Reference. Best practice for JVM Tuning with G1 GC