我目前正在调查压缩类空间问题。我知道问题出在哪里,但在调查时,我注意到jstat -gc ...
并jcmd ... GC.heap_info
给出了不同数量的元空间和压缩类空间容量和使用情况:
▶ jcmd 32152 GC.heap_info
32152:
PSYoungGen total 153600K, used 129316K [0x00000000eab00000, 0x00000000f5b00000, 0x0000000100000000)
eden space 137728K, 91% used [0x00000000eab00000,0x00000000f26abf48,0x00000000f3180000)
from space 15872K, 16% used [0x00000000f4100000,0x00000000f439d428,0x00000000f5080000)
to space 15872K, 0% used [0x00000000f3180000,0x00000000f3180000,0x00000000f4100000)
ParOldGen total 290816K, used 21446K [0x00000000c0000000, 0x00000000d1c00000, 0x00000000eab00000)
object space 290816K, 7% used [0x00000000c0000000,0x00000000c14f1ac0,0x00000000d1c00000)
Metaspace used 59690K, capacity 64980K, committed 65192K, reserved 1103872K
class space used 9289K, capacity 10116K, committed 10152K, reserved 1048576K
▶ jstat -gc 32152
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
15872.0 15872.0 2677.0 0.0 137728.0 126711.2 290816.0 21446.7 63400.0 58060.7 9896.0 9067.2 8 0.047 3 0.118 0.164
堆容量的数字似乎大致匹配(幸存者、伊甸园和老一代的所有容量都同意)。堆使用数字不完全匹配,但我不希望它们匹配;jstat
在这里大约一秒钟后被收集jcm
。但是元空间数字全部关闭,jstat
数字通常略低于jcmd
数字。我重新运行了这两个命令以确认调用之间没有发生类加载,实际上,这两个命令都为元空间编号提供了与以前相同的输出。
这里发生了什么?他们测量这些数字的方式是否略有不同?哪个更准确?
运行时信息:
JVM: Java HotSpot(TM) 64-Bit Server VM (25.202-b08, mixed mode)
Java: version 1.8.0_202, vendor Oracle Corporation
-Xmx1024m
-XX:+UseParallelGC