查看监控Heap size 和 JVM 垃圾回收情况
尤其是GC情况的监控,如果老年代发生Full GC,那么很可能会导致内存泄漏的可能性。
jstat -gcutil PID
jstat -gcutil PID 1s
会每隔一秒输出内存相关信息,示例输出如下:
输出列内容说明:
S0: Survivor 0区的空间使用率 Survivor space 0 utilization as a percentage of the space's current capacity.
S1: Survivor 1区的空间使用率 Survivor space 1 utilization as a percentage of the space's current capacity.
E: Eden区的空间使用率 Eden space utilization as a percentage of the space's current capacity.
O: 老年代的空间使用率 Old space utilization as a percentage of the space's current capacity.
M: 元数据的空间使用率 Metaspace utilization as a percentage of the space's current capacity.
CCS: 类指针压缩空间使用率 Compressed class space utilization as a percentage.
YGC: 新生代GC次数 Number of young generation GC events.
YGCT: 新生代GC总时长(从应用程序启动到采样时年轻代中gc所用时间 单位:s)Young generation garbage collection time.
FGC: Full GC次数 Number of full GC events.
FGCT: Full GC总时长(从应用程序启动到采样时old代(全gc)gc所用时间 单位:s)Full garbage collection time.
GCT: 总共的GC时长 (从应用程序启动到采样时gc用的总时间 单位:s)Total garbage collection time.
jstat -gc <pid> 1s 会输出具体占用的数值(KB)。
输出列说明如下:
SOC 第 0 个 Survivor 区的总空间 (KB).
S1C 第 1 个 Survivor 区的总空间 (KB).
S0U 第 0 个 Survivor 区已使用的空间 (KB).
S1U 第 1 个 Survivor 区已使用的空间 (KB).
EC Eden 区的总空间 (KB).
EU Eden 区已使用的空间 (KB).
OC OldGen 的总空间 (KB).
OU OldGen 已使用的空间 (KB).
PC/MC PermGen / MetaSpace 的总空间 (KB).
PU/MU PermGen / MetaSpace 使用的空间 (KB).
YGC 程序启动以来 Young GC 发生的次数.
YGCT 程序启动以来 Young GC 共消耗的时间(s).
FGC 程序启动以来 Full GC 发生的次数.
FGCT 程序启动以来 Young GC 共消耗的时间(s).
GCT 程序启动以来 GC 的总用时(s).