相关脚本:
# if os memory <= 2G
if [ $memTotal -le 2048 ]; then
SERVICE_OPTS="${SERVICE_OPTS} -Xms1536m -Xmx1536m"
SERVICE_OPTS="${SERVICE_OPTS} -Xmn768m"
else
SERVICE_OPTS="${SERVICE_OPTS} -Xms5g -Xmx5g -XX:MaxNewSize=3g"
#SERVICE_OPTS="${SERVICE_OPTS} -Xmn3g"
fi
#使用G1回收器
SERVICE_OPTS="${SERVICE_OPTS} -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=256m"
SERVICE_OPTS="${SERVICE_OPTS} -XX:MaxDirectMemorySize=512m"
SERVICE_OPTS="${SERVICE_OPTS} -XX:+UseG1GC -XX:InitiatingHeapOccupancyPercent=50 -XX:G1HeapRegionSize=8m"
SERVICE_OPTS="${SERVICE_OPTS} -XX:+ExplicitGCInvokesConcurrent -XX:ParallelGCThreads=4"
#关闭使用吞吐量优先的新生代与老年代的并行GC
#SERVICE_OPTS="${SERVICE_OPTS} -XX:+UseParallelGC"
#SERVICE_OPTS="${SERVICE_OPTS} -XX:+UseParallelOldGC"
#SERVICE_OPTS="${SERVICE_OPTS} -XX:ParallelGCThreads=${CPU_COUNT}"
#关闭CMS GC
#SERVICE_OPTS="${SERVICE_OPTS} -XX:+UseConcMarkSweepGC -XX:CMSMaxAbortablePrecleanTime=5000"
#SERVICE_OPTS="${SERVICE_OPTS} -XX:+CMSClassUnloadingEnabled -XX:CMSInitiatingOccupancyFraction=80 -XX:+UseCMSInitiatingOccupancyOnly"
SERVICE_OPTS="${SERVICE_OPTS} -XX:+ExplicitGCInvokesConcurrent -Dsun.rmi.dgc.server.gcInterval=2592000000 -Dsun.rmi.dgc.client.gcInterval=2592000000"