jcmd <pid> VM.native_memory
的输出显示了Class
和Metaspace
部分,如下所示
Class (reserved=1053604KB, committed=39012KB)
(classes #46737)
( instance classes #44474, array classes #2263)
(malloc=5028KB #107972) (peak=5042KB #107808)
(mmap: reserved=1048576KB, committed=33984KB)
( Metadata: )
( reserved=262144KB, committed=257280KB)
( used=255927KB)
( waste=1353KB =0.53%)
( Class space:)
( reserved=1048576KB, committed=33984KB)
( used=32654KB)
( waste=1330KB =3.91%)
和
Metaspace (reserved=263756KB, committed=258892KB)
(malloc=1612KB #1525) (at peak)
(mmap: reserved=262144KB, committed=257280KB)
有人可以告诉我
Class
和 Metaspace
部分之间的区别吗? Metadata
下显示的Class
和Metaspace
一样吗?
输出
java -version
openjdk version "17.0.11" 2024-04-16
OpenJDK Runtime Environment Temurin-17.0.11+9 (build 17.0.11+9)
OpenJDK 64-Bit Server VM Temurin-17.0.11+9 (build 17.0.11+9, mixed mode, sharing)
正如@apangin在评论中指出的,从问题中
Class (reserved=1053604KB
指的是Compressed Class Space
,Metaspace (reserved=263756KB
指的是非类空间。如需更多解释,请阅读 this 和 @apangin 的答案。