You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Specify a higher value for the option MetaspaceSize to avoid early garbage collections induced for class metadata. The amount of class metadata allocated for an application is application-dependent and general guidelines do not exist for the selection of MetaspaceSize. The default size of MetaspaceSize is platform-dependent and ranges from 12 MB to about 20 MB.
voidMetaspaceGC::initialize() {
// Set the high-water mark to MaxMetapaceSize during VM initializaton since// we can't do a GC during initialization._capacity_until_GC=MaxMetaspaceSize;
}
Activity
Snailclimb commentedon Mar 12, 2023
感谢指出,已经修正。
1、Metaspace 的初始容量并不是
-XX:MetaspaceSize设置,无论-XX:MetaspaceSize配置什么值,对于 64 位 JVM 来说,Metaspace 的初始容量都是 21807104(约 20.8m)。可以参考 Oracle 官方文档 Other Considerations中提到的:
另外,还可以看一下这个试验:JVM 参数 MetaspaceSize 的误解。
2、Metaspace 由于使用不断扩容到
-XX:MetaspaceSize参数指定的量,就会发生 FGC,且之后每次 Metaspace 扩容都会发生 Full GC。也就是说,MetaspaceSize 表示 Metaspace 使用过程中触发 Full GC 的阈值,只对触发起作用。
垃圾搜集器内部是根据变量
_capacity_until_GC来判断 Metaspace 区域是否达到阈值的,初始化代码如下所示:Snailclimb commentedon Aug 24, 2026
感谢反馈!这个问题已经在当前文档中修复:docs/java/jvm/jvm-parameters-intro.md 已补充修正说明:-XX:MetaspaceSize 是触发元数据 GC 的高水位阈值,并非初始容量。 如果觉得仍有问题,欢迎重新打开或新开 issue 说明。