参数模版

    -server
    -Xms<heap size>[g|m|k] -Xmx<heap size>[g|m|k]
    -XX:PermSize=<perm gen size>[g|m|k] -XX:MaxPermSize=<perm gen size>[g|m|k]
    -Xmn<young size>[g|m|k]
    -XX:SurvivorRatio=<ratio>
    -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
    -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=<percent>
    -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark
    -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"
    -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
    -Dsun.net.inetaddr.ttl=<TTL in seconds>
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump>`date`.hprof
    -Djava.rmi.server.hostname=<external IP>
    -Dcom.sun.management.jmxremote.port=<port> 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false
    -server
    -Xms<heap size>[g|m|k] -Xmx<heap size>[g|m|k]
    -XX:MaxMetaspaceSize=<metaspace size>[g|m|k]
    -Xmn<young size>[g|m|k]
    -XX:SurvivorRatio=<ratio>
    -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
    -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=<percent>
    -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark
    -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"
    -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
    -Dsun.net.inetaddr.ttl=<TTL in seconds>
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump>`date`.hprof
    -Djava.rmi.server.hostname=<external IP>
    -Dcom.sun.management.jmxremote.port=<port> 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false

参数说明

#开启server模式
    -server
# heap 最大、最小值
    -Xms<heap size>[g|m|k] -Xmx<heap size>[g|m|k]
#元空间大小
    -XX:MaxMetaspaceSize=<metaspace size>[g|m|k]
#Eden大小
    -Xmn<young size>[g|m|k]
#SurvivorRatio比例,ratio=Y,代表年轻代共(Y+2),其中eden=Y,from=to=1,
    -XX:SurvivorRatio=<ratio>
#使用CMS回收算法
    -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled
#CMSInitiatingOccupancyFraction informs Java VM when CMS should be triggered
#一般70
    -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=<percent>
    -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark
#打印GC日志
    -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"<path to log>"
    -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M
#Number of seconds during which DNS record will be cached in Java VM
    -Dsun.net.inetaddr.ttl=<TTL in seconds>
#Dump on Out of Memory
    -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path to dump>`date`.hprof
#启用JMX
    -Djava.rmi.server.hostname=<external IP>
    -Dcom.sun.management.jmxremote.port=<port> 
    -Dcom.sun.management.jmxremote.authenticate=false 
    -Dcom.sun.management.jmxremote.ssl=false

实际例子

java \\
 -Denv=prod \\
 -Dspring.profiles.active=prod \\
 -Duser.timezone=GMT+08 \\
 -server \\
 -Xms2048m \\
 -Xmx2048m \\
 -Xmn1024m \\
 -XX:SurvivorRatio=8 \\
 -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled \\
 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 \\
 -XX:+ScavengeBeforeFullGC -XX:+CMSScavengeBeforeRemark \\
 -XX:+PrintGCDateStamps -verbose:gc -XX:+PrintGCDetails -Xloggc:"/tmp/gc.log" \\
 -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M \\
 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath="/tmp/heapdump.`date +%Y-%m-%`.hprof" \\
 -Dsun.net.inetaddr.ttl=60 \\
 -jar ./bjx-server.jar \\
 --server.port=80

Refer

Java VM Options You Should Always Use in Production

JVM优化之 -Xss -Xms -Xmx -Xmn 参数设置

Java HotSpot VM

For Java 7 and earlier

Java 8