jcmd 的 GC.class_stats 子命令

jcmd 的 GC.class_stats 子命令 输出 JVM 里metaspace (元数据)区的 class 相关的信息. 这里必须记住, 所有的 java.lang.Class 及其子类都在heap, 元数据区只是这些class的元数据, 元数据区存的也不是这些类编译后的字节码(bytescode).

GC.class_stats 能输出每个class 在 metaspace 空间占用的大小.

这个子命令在JDK 14 deprecated, 15去掉.

默认只输出下面这些列, 还有更多列可以显示, 需要指定列名称:

InstBytes,KlassBytes,CpAll,annotations,MethodCount,Bytecodes,MethodAll,ROAll,RWAll,Total
$ bin/jcmd <pid> GC.class_stats

由于类太多, 并且长度会折叠, 这里截图开头和结尾的截图:
head.png
tail.png

最好结合 jcmd <pid> VM.metaspace 一起看
vmMetaspace.png

关于任意每列的具体含义, 使用 jcmd <pid> GC.class_stats -help 查看:

InstSize:

Size of each object instance of the Java class. 每个实例的shallow size

InstCount:

Number of object instances of the Java class. heap 实例个数

InstBytes:

This is usually (InstSize * InstNum). The only exception is java.lang.Class,
whose InstBytes also includes the slots used to store static
fields. InstBytes is not counted in ROAll, RWAll or Total. 所有实例占用heap的大小

Mirror:

Size of the Klass::java_mirror() object.

KlassBytes:

Size of the InstanceKlass or ArrayKlass for this class. Note
that this includes VTab, ITab, OopMap.

K_secondary_supers:

Number of bytes used by the Klass::secondary_supers() array.

VTab:

Size of the embedded vtable in InstanceKlass.

ITab:

Size of the embedded itable in InstanceKlass.

OopMap:

Size of the embedded nonstatic_oop_map in InstanceKlass.

IK_methods:

Number of bytes used by the InstanceKlass::methods() array.

IK_method_ordering:

Number of bytes used by the InstanceKlass::method_ordering()
array.

IK_default_methods:

Number of bytes used by the InstanceKlass::default_methods()
array.

IK_default_vtable_indices:

Number of bytes used by the InstanceKlass::default_vtable_indices()
array.

IK_local_interfaces:

Number of bytes used by the InstanceKlass::local_interfaces()
array.

IK_transitive_interfaces:

Number of bytes used by the InstanceKlass::transitive_interfaces()
array.

IK_fields:

Number of bytes used by the InstanceKlass::fields() array.

IK_inner_classes:

Number of bytes used by the InstanceKlass::inner_classes() array.

IK_nest_members:

Number of bytes used by the InstanceKlass::nest_members() array.

IK_signers:

Number of bytes used by the InstanceKlass::singers() array.

class_annotations:

Size of class annotations. 

class_type_annotations:

Size of class type annotations.

fields_annotations:

Size of field annotations.

fields_type_annotations:

Size of field type annotations.

methods_annotations:

Size of method annotations.

methods_parameter_annotations:

Size of method parameter annotations.

methods_type_annotations:

Size of methods type annotations.

methods_default_annotations:

Size of methods default annotations.

annotations:

Size of all annotations.

Cp:

Size of InstanceKlass::constants().

CpTags:

Size of InstanceKlass::constants()->tags().

CpCache:

Size of InstanceKlass::constants()->cache().

CpOperands:

Size of InstanceKlass::constants()->operands().

CpRefMap:

Size of InstanceKlass::constants()->reference_map().

CpAll:

Sum of Cp + CpTags + CpCache + CpOperands + CpRefMap.

MethodCount:

Number of methods in this class.

MethodBytes:

Size of the Method object.

ConstMethod:

Size of the ConstMethod object.

MethodData:

Size of the MethodData object.

StackMap:

Size of the stackmap_data.

Bytecodes:

Of the MethodBytes column, how much are the space taken up by
bytecodes.

MethodAll:

Sum of MethodBytes + Constmethod + Stackmap + Methoddata.

ROAll:

Size of all class meta data that could (potentially) be placed
in read-only memory. (This could change with CDS design).

RWAll:

Size of all class meta data that must be placed in read/write
memory. (This could change with CDS design) .

Total:

ROAll + RWAll. Note that this does NOT include InstBytes..

标签: none

添加新评论