一、运行jmap命令
JDK8环境下运行jmap命令:
[root@wechatrobotapp-6d68998864-s4qgx tomcat]# jmap -heap 1
Attaching to process ID 1, please wait...
Debugger attached successfully.
Server compiler detected.
JVM version is 25.231-b11
using thread-local object allocation.
Parallel GC with 3 thread(s)
Heap Configuration:
MinHeapFreeRatio = 0
MaxHeapFreeRatio = 100
MaxHeapSize = 3277848576 (3126.0MB)
NewSize = 1030750208 (983.0MB)
MaxNewSize = 1030750208 (983.0MB)
OldSize = 609222656 (581.0MB)
NewRatio = 2
SurvivorRatio = 8
MetaspaceSize = 21807104 (20.796875MB)
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
G1HeapRegionSize = 0 (0.0MB)
Heap Usage:
PS Young Generation
Eden Space:
capacity = 1020264448 (973.0MB)
used = 56929240 (54.291954040527344MB)
free = 963335208 (918.7080459594727MB)
5.579851391626654% used
From Space:
capacity = 5242880 (5.0MB)
used = 4875696 (4.6498260498046875MB)
free = 367184 (0.3501739501953125MB)
92.99652099609375% used
To Space:
capacity = 5242880 (5.0MB)
used = 0 (0.0MB)
free = 5242880 (5.0MB)
0.0% used
PS Old Generation
capacity = 950009856 (906.0MB)
used = 109103912 (104.04959869384766MB)
free = 840905944 (801.9504013061523MB)
11.484503167091352% used
38470 interned Strings occupying 4250544 bytes.
二、堆配置
MinHeapFreeRatio = 0
空闲堆空间的最小百分比,计算公式为:HeapFreeRatio =(CurrentFreeHeapSize/CurrentTotalHeapSize) * 100,值的区间为0到100,默认值为 40。如果HeapFreeRatio < MinHeapFreeRatio,则需要进行堆扩容,扩容的时机应该在每次垃圾回收之后。
MaxHeapFreeRatio = 100
空闲堆空间的最大百分比,计算公式为:HeapFreeRatio =(CurrentFreeHeapSize/CurrentTotalHeapSize) * 100,值的区间为0到100,默认值为 70。如果HeapFreeRatio > MaxHeapFreeRatio,则需要进行堆缩容,缩容的时机应该在每次垃圾回收之后。
备注:在正式环境中,JVM -Xmx和-Xms一般设置为相同的容量。避免堆扩容和缩容导致的STW。所以上面两个参数实际参考意义不大
MaxHeapSize = 3277848576 (3126.0MB)
JVM 堆空间允许的最大值
NewSize = 1030750208 (983.0MB)
JVM 新生代堆空间的默认值。
MaxNewSize = 1030750208 (983.0MB)
JVM 新生代堆空间允许的最大值。
OldSize = 609222656 (581.0MB)
JVM 老年代堆空间的默认值。
NewRatio = 2
新生代(2个Survivor区和Eden区 )与老年代(不包括永久区)的堆空间比值,表示新生代:老年代=1:2。
SurvivorRatio = 8
两个Survivor区和Eden区的堆空间比值为 8,表示 S0 : S1 :Eden = 1:1:8
MetaspaceSize = 21807104 (20.796875MB)
JVM 元空间的默认值
CompressedClassSpaceSize = 1073741824 (1024.0MB)
MaxMetaspaceSize = 17592186044415 MB
JVM 元空间允许的最大值。