JVM参数优化实例

JDK版本

image

jvm参数:

-Xms24g 
-Xmx24g 
-Xmn12g 
-XX:SurvivorRatio=8 
-XX:MetaspaceSize=256m 
-XX:MaxMetaspaceSize=512m 
-XX:+UseConcMarkSweepGC 
-XX:+HeapDumpOnOutOfMemoryError 
-XX:HeapDumpPath=./heapdump.hprof 
-XX:+UseGCOverheadLimit 
-Xloggc:gc.log 
-XX:+PrintGCDetails 
-XX:+PrintGCDateStamps 
-XX:+UseGCLogFileRotation 
-XX:NumberOfGCLogFiles=8 
-XX:GCLogFileSize=512k 
-XX:+PrintHeapAtGC

运行15min时

jvm情况

总内存
image

元数据区
image

老年代
image

年轻代

image

垃圾回收次数
image

垃圾回收时长
image

每个物理CPU的核心数
image

优化后

-Xms24g
-Xmx24g
-Xmn18g
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=256m
-XX:SurvivorRatio=8
-XX:-UseBiasedLocking
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:ConcGCThreads=8
-XX:ParallelGCThreads=8
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=92
-XX:-OmitStackTraceInFastThrow
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./heapdump.hprof
-XX:+UseGCOverheadLimit
-Xloggc:gc.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=8
-XX:GCLogFileSize=512k
-XX:+PrintHeapAtGC

image

image

image

image

image

image

image

image

运行4个小时

image

image

image

image

image

image

image

image

image

运行10小时

年轻代扩大至22g

-Xms24g
-Xmx24g
-Xmn22g
-XX:MetaspaceSize=256m
-XX:MaxMetaspaceSize=256m
-XX:SurvivorRatio=8
-XX:-UseBiasedLocking
-XX:+UseParNewGC
-XX:+UseConcMarkSweepGC
-XX:ConcGCThreads=8
-XX:ParallelGCThreads=8
-XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=92
-XX:-OmitStackTraceInFastThrow
-XX:+ExplicitGCInvokesConcurrentAndUnloadsClasses
-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./heapdump.hprof
-XX:+UseGCOverheadLimit
-Xloggc:gc.log
-XX:+PrintGCDetails
-XX:+PrintGCDateStamps
-XX:+UseGCLogFileRotation
-XX:NumberOfGCLogFiles=8
-XX:GCLogFileSize=512k
-XX:+PrintHeapAtGC

image

image

image

image

image

image

image

image

image

image

image

总览

image

——————————————————————————————分割线——————————————————————————————
运行了一天的情况

image

image

image

image

image

image

image

image

image

image

image

image

posted @ 2024-08-19 16:26  Reecelin  阅读(4)  评论(0编辑  收藏  举报