JVM Statistics Monitoring Tool,是用於監視虛擬機運行時狀態信息的命令,它可以顯示出虛擬機進程中的類裝載、內存、垃圾收集、JIT編譯等運行數據。【性能分析】
命令格式
1
|
jstat [options] VMID [interval] [count]
|
參數
[options] : 操作參數,
一般使用 -gcutil 查看gc情況
VMID : 本地虛擬機進程ID, 即當前運行的java進程號
[interval] : 連續輸出的時間間隔,單位為秒或者毫秒
[count] : 連續輸出的次數,如果缺省打印無數次
VMID : 本地虛擬機進程ID, 即當前運行的java進程號
[interval] : 連續輸出的時間間隔,單位為秒或者毫秒
[count] : 連續輸出的次數,如果缺省打印無數次
option 參數總覽
Option | Displays |
---|---|
class | 類加載的行為統計。Statistics on the behavior of the class loader. |
compiler | HotSpt JIT編譯器行為統計。Statistics of the behavior of the HotSpot Just-in-Time compiler. |
gc | 垃圾回收堆的行為統計。Statistics of the behavior of the garbage collected heap. |
gccapacity | 各個垃圾回收代容量(young,old,perm)和他們相應的空間統計。Statistics of the capacities of the generations and their corresponding spaces. |
gcutil | 垃圾回收統計概述(百分比)。Summary of garbage collection statistics. |
gccause | 垃圾收集統計概述(同-gcutil),附加最近兩次垃圾回收事件的原因。Summary of garbage collection statistics (same as -gcutil), with the cause of the last and |
gcnew | 新生代行為統計。Statistics of the behavior of the new generation. |
gcnewcapacity | 新生代與其相應的內存空間的統計。Statistics of the sizes of the new generations and its corresponding spaces. |
gcold | 年老代和永生代行為統計。Statistics of the behavior of the old and permanent generations. |
gcoldcapacity | 年老代行為統計。Statistics of the sizes of the old generation. |
gcpermcapacity | 永生代行為統計。Statistics of the sizes of the permanent generation. |
printcompilation | HotSpot編譯方法統計。HotSpot compilation method statistics. |
option 參數詳解
-class (監視類裝載、卸載數量、總空間以及耗費的時間)
1
2
3
4
|
[root@localhost bin]
# jstat -class 4513
Loaded Bytes Unloaded Bytes Time
8455 17240.8 0 0.0 15.47
|
Loaded : 加載class的數量
Bytes : class字節大小
Unloaded : 未加載class的數量
Bytes : 未加載class的字節大小
Time : 加載時間
Bytes : class字節大小
Unloaded : 未加載class的數量
Bytes : 未加載class的字節大小
Time : 加載時間
-compiler(輸出JIT編譯過的方法數量耗時等)
1
2
3
|
[root@localhost bin]
# jstat -compiler 4513
Compiled Failed Invalid Time FailedType FailedMethod
1255 0 0 16.47 0
|
Compiled : 編譯數量
Failed : 編譯失敗數量
Invalid : 無效數量
Time : 編譯耗時
FailedType : 失敗類型
FailedMethod : 失敗方法的全限定名
Failed : 編譯失敗數量
Invalid : 無效數量
Time : 編譯耗時
FailedType : 失敗類型
FailedMethod : 失敗方法的全限定名
-gc(垃圾回收堆的行為統計,常用命令)
1
2
3
|
[root@localhost bin]
# jstat -gc 4513
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
52224.0 53248.0 19364.2 0.0 804864.0 74967.7 168448.0 80595.4 52736.0 52628.1 10 0.232 0 0.000 0.232
|
C即Capacity 總容量,U即Used 已使用的容量
S0C : survivor0區的總容量
S1C : survivor1區的總容量
S0U : survivor0區已使用的容量
S1C : survivor1區已使用的容量
EC : Eden區的總容量
EU : Eden區已使用的容量
OC : Old區的總容量
OU : Old區已使用的容量
PC : 當前perm的容量 (KB)
PU : perm的使用 (KB)
YGC : 新生代垃圾回收次數
YGCT : 新生代垃圾回收時間
FGC : 老年代垃圾回收次數
FGCT : 老年代垃圾回收時間
GCT : 垃圾回收總消耗時間
S1C : survivor1區的總容量
S0U : survivor0區已使用的容量
S1C : survivor1區已使用的容量
EC : Eden區的總容量
EU : Eden區已使用的容量
OC : Old區的總容量
OU : Old區已使用的容量
PC : 當前perm的容量 (KB)
PU : perm的使用 (KB)
YGC : 新生代垃圾回收次數
YGCT : 新生代垃圾回收時間
FGC : 老年代垃圾回收次數
FGCT : 老年代垃圾回收時間
GCT : 垃圾回收總消耗時間
1
|
[root@localhost bin]
# jstat -gc 4513 2000 2
|
這個命令意思就是每隔2000ms輸出4513的gc情況,一共輸出2次
-gccapacity(同-gc,還會輸出Java堆各區域使用到的最大、最小空間)
1
2
3
|
[root@localhost bin]
# jstat -gccapacity 4513
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC
84480.0 1349632.0 913408.0 54272.0 51200.0 502784.0 168448.0 2699264.0 168448.0 168448.0 21504.0 83968.0 51712.0 51712.0 9 0
|
NGCMN : 新生代占用的最小空間
NGCMX : 新生代占用的最大空間
OGCMN : 老年代占用的最小空間
OGCMX : 老年代占用的最大空間
OGC:當前年老代的容量 (KB)
OC:當前年老代的空間 (KB)
PGCMN : perm占用的最小空間
PGCMX : perm占用的最大空間
NGCMX : 新生代占用的最大空間
OGCMN : 老年代占用的最小空間
OGCMX : 老年代占用的最大空間
OGC:當前年老代的容量 (KB)
OC:當前年老代的空間 (KB)
PGCMN : perm占用的最小空間
PGCMX : perm占用的最大空間
-gcutil(同-gc,輸出的是已使用空間占總空間的百分比)
1
2
3
|
[root@localhost bin]
# jstat -gcutil 4513
S0 S1 E O P YGC YGCT FGC FGCT GCT
0.00 79.23 38.90 39.92 99.74 9 0.198 0 0.000 0.198
|
-gccause(垃圾收集統計概述(同-gcutil),附加最近兩次垃圾回收事件的原因)
1
2
3
|
[root@localhost bin]
# jstat -gccause 4513
S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC
0.00 79.23 39.37 39.92 99.74 9 0.198 0 0.000 0.198 Allocation Failure No GC
|
LGCC:最近垃圾回收的原因
GCC:當前垃圾回收的原因
GCC:當前垃圾回收的原因
-gcnew(統計新生代行為)
1
2
3
|
[root@localhost bin]
# jstat -gcnew 4513
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
54272.0 51200.0 0.0 40565.8 2 15 54272.0 502784.0 197950.5 9 0.198
|
TT:Tenuring threshold(提升閾值)
MTT:最大的tenuring threshold
DSS:survivor區域大小 (KB)
MTT:最大的tenuring threshold
DSS:survivor區域大小 (KB)
-gcnewcapacity(新生代與其相應的內存空間的統計)
1
2
3
|
[root@localhost bin]
# jstat -gcnewcapacity 4513
NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC
84480.0 1349632.0 913408.0 449536.0 54272.0 449536.0 51200.0 1348608.0 502784.0 9 0
|
NGC:當前年輕代的容量 (KB)
S0CMX:最大的S0空間 (KB)
S0C:當前S0空間 (KB)
ECMX:最大eden空間 (KB)
EC:當前eden空間 (KB)
S0CMX:最大的S0空間 (KB)
S0C:當前S0空間 (KB)
ECMX:最大eden空間 (KB)
EC:當前eden空間 (KB)
-gcold(統計老年代行為)
1
2
3
|
[root@localhost bin]
# jstat -gcold 4513
PC PU OC OU YGC FGC FGCT GCT
51712.0 51575.1 168448.0 67239.6 9 0 0.000 0.198
|
-gcoldcapacity(老年代與其相應的內存空間的統計)
1
2
3
|
[root@localhost bin]
# jstat -gcoldcapacity 4513
OGCMN OGCMX OGC OC YGC FGC FGCT GCT
168448.0 2699264.0 168448.0 168448.0 9 0 0.000 0.198
|
-gcpermcapacity(永久代與其相應內存空間的統計)
1
2
3
|
[root@localhost bin]
# jstat -gcpermcapacity 4513
PGCMN PGCMX PGC PC YGC FGC FGCT GCT
21504.0 83968.0 51712.0 51712.0 9 0 0.000 0.19
|
-printcompilation(hotspot編譯方法統計)
1
2
3
|
[root@localhost bin]
# jstat -printcompilation 4513
Compiled Size Type Method
1261 1261 1 java
/util/concurrent/ScheduledThreadPoolExecutor
$DelayedWorkQueue take
|
Compiled:被執行的編譯任務的數量
Size:方法字節碼的字節數
Type:編譯類型
Method:編譯方法的類名和方法名。類名使用"/" 代替 "." 作為空間分隔符. 方法名是給出類的方法名. 格式是一致於HotSpot - XX:+PrintComplation 選項
Size:方法字節碼的字節數
Type:編譯類型
Method:編譯方法的類名和方法名。類名使用"/" 代替 "." 作為空間分隔符. 方法名是給出類的方法名. 格式是一致於HotSpot - XX:+PrintComplation 選項