在Java 8堆打印输出中,您可能会看到如下所示的行:
Metaspace used 2425K, capacity 4498K, committed 4864K, reserved 1056768K
In the line beginning with Metaspace, the used value is the amount of space used for loaded classes. The capacity value is the space available for metadata in currently allocated chunks. The committed value is the amount of space available for chunks. The reserved value is the amount of space reserved (but not necessarily committed) for metadata.
再次,从上面的链接:
Space is requested from the OS and then divided into chunks. A class loader allocates space for metadata from its chunks (a chunk is bound to a specific class loader).
我想知道每个字段的含义(使用,容量,承诺,保留),但我很难理解上面的定义.
我的理解是,metaspace是从JVM进程的虚拟地址空间中划分出来的. JVM在启动时保留初始大小,基于-XX:MetaspaceSize,它具有未记录的,特定于平台的默认值.我假设保留是指元空间的总大小.空间分为块.我不确定每个块是否具有相同的大小.每个块包含与单个类加载器关联的类元数据.
容量和承诺的声音对我来说就像是免费空间(基于链接的定义).由于元数据存储在块中,因此我假设已使用的容量等于已提交,但事实并非如此.也许承诺意味着使用的保留空间,但那么使用的意思是什么?元数据使用的空间?那么,还有什么方法可以使用这个空间?
我希望你看到我的困惑.我希望澄清这些定义.