-
Notifications
You must be signed in to change notification settings - Fork 45.9k
Open
Labels
doc-bugContent errorContent error
Description
JVM 参数章节 jvm-parameters-intro.md: L98 中提到:
-XX:MetaspaceSize=N #设置 Metaspace 的初始(和最小大小)
此处解释错误,即 Metaspace 的初始大小非由 -XX:MetaspaceSize
设置。
参见 Oracle 官方文档 Other Considerations 中提到:
When the space committed for class metadata reaches a certain level (a high-water mark), a garbage collection is induced.
The high-water mark is initially set to the value of the command-line option MetaspaceSize.
可见 -XX:MetaspaceSize
是一个提前设定的阈值,会触发 GC,那一定不是初始大小。
通过实验证实 Metaspace 的初始大小非由 -XX:MetaspaceSize
设置,而是会引起 Full GC,过程详见:
V11Playko
Metadata
Metadata
Assignees
Labels
doc-bugContent errorContent error
Projects
Milestone
Relationships
Development
Select code repository
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 区域是否达到阈值的,初始化代码如下所示: