1.查看當前java進程的pid
pgrep -lf java
2.查看java堆的詳細信息
jmap -heap PID
3.查看java堆中對象的相關信息,包含數量以及佔用的空間大小
jmap -histo PID
4.查看監控 heap size 和 jvm垃圾回收情況,尤其是gc情況的監控,如果老年代發生full gc,那麼很可能會導致內存泄漏的可能性
jstat -gcutil pid
屬性參照:
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.
注:full gc很具有代表性,full gc次數 和時間 指標很能顯示系統性能問題,這兩個指標很大,很大程度上說明了程序中有問題,垃圾一直回收不掉