CompressedClassSpaceSize 区域是否包含 MaxMetaspaceSize 区域?
什么是CompressedClassSpaceSize
?
CompressedClassSpaceSize
和MetaspaceSize
是什么关系?
推荐答案
Metaspace 是用于存储类元数据的内存区域 - 解析 .class
文件时创建的内部 JVM 结构.
Metaspace is the memory area for storing class metadata - internal JVM structures created while parsing .class
files.
类元数据包括:
- Java 类的内部表示
- 方法及其字节码
- 字段描述符
- 恒定池
- 符号
- 注释
- 等等
-XX:MaxMetaspaceSize
默认无限制.
当 -XX:+UseCompressedClassPointers
选项为 ON(堆 <32G 的默认值)时,类从 Metaspace 移动到称为 Compressed Class Space 的单独区域.这是为了允许使用 32 位值而不是 64 位来寻址 VM 类结构.
When -XX:+UseCompressedClassPointers
option is ON (default for heaps < 32G), classes are moved from Metaspace to the separate area called Compressed Class Space. This is to allow addressing VM class structures with 32-bit values instead of 64-bit.
因此,Compressed Class Space 包含 Java 类的内部表示,而 Metaspace 包含所有其他元数据:方法、常量池、注释等.
So, Compressed Class Space contains internal representation of Java classes, while Metaspace holds all the rest metadata: methods, constant pools, annotations, etc.
Compressed Class Space的大小受-XX:CompressedClassSpaceSize
限制,默认为1G.-XX:CompressedClassSpaceSize
的最大可能值为3G.
The size of Compressed Class Space is limited by -XX:CompressedClassSpaceSize
, which is 1G by default. The maximum possible value of -XX:CompressedClassSpaceSize
is 3G.
非类元空间和压缩类空间是两个不相交的区域.MaxMetaspaceSize
限制两个区域的提交大小:
Non-class Metaspace and Compressed Class Space are two disjoint areas. MaxMetaspaceSize
limits the committed size of both areas:
committed(Non-class Metaspace) + committed(Compressed Class Space) <= MaxMetaspaceSize
如果MaxMetaspaceSize
设置小于CompressedClassSpaceSize
,后者自动减小到
If MaxMetaspaceSize
is set smaller than CompressedClassSpaceSize
, the latter is automatically decreased to
CompressedClassSpaceSize = MaxMetaspaceSize - 2*InitialBootClassLoaderMetaspaceSize
相关文章