我正在研究如何调试应用程序中的“OutOfMemoryError: Metaspace”错误。在OOME之前,我在gc日志中看到以下内容:
{Heap before GC invocations=6104 (full 39):
par new generation total 943744K, used 0K [...)
eden space 838912K, 0% used [...)
from space 104832K, 0% used [...)
to space 104832K, 0% used [...)
concurrent mark-sweep generation total 2097152K, used 624109K [...)
Metaspace used 352638K, capacity 487488K, committed 786432K, reserved 1775616K
class space used 36291K, capacity 40194K, committed 59988K, reserved 1048576K
2015-08-11T20:34:13.303+0000: 105892.129: [Full GC (Last ditch collection) 105892.129: [CMS: 624109K->623387K(2097152K), 3.4208207 secs] 624109K->623387K(3040896K), [Metaspace: 352638K->352638K(1775616K)], 3.4215100 secs] [Times: user=3.42 sys=0.00, real=3.42 secs]
Heap after GC invocations=6105 (full 40):
par new generation total 943744K, used 0K [...)
eden space 838912K, 0% used [...)
from space 104832K, 0% used [...)
to space 104832K, 0% used [...)
concurrent mark-sweep generation total 2097152K, used 623387K [...)
Metaspace used 352638K, capacity 487488K, committed 786432K, reserved 1775616K
class space used 36291K, capacity 40194K, committed 59988K, reserved 1048576K
}
据我所见,元空间容量甚至没有接近已承诺的大小(在这种情况下,
-XX:MaxMetaspaceSize=768m
)。因此,我怀疑元空间的碎片化导致分配器无法为新类加载器找到新的块。我知道有
-XX:PrintFLSStatistics
,但它只涵盖CMS,而不涉及本机内存。因此,我的问题是:是否有类似于
PrintFLSStatistics
的调试帮助可用于Hotspot的本机内存?这是使用Java HotSpot(TM) 64位服务器VM (25.45-b02) for linux-amd64 JRE (1.8.0_45-b14)。