Jstat是Sun JDK中自帶的監控工具,利用了JVM內建的指令對Java應用程序的資源和性能進行實時的命令行的監控,包括了對Heap size和垃圾回收狀況的監控等等。JStat是命令行方式運行,對系統資源佔用很小,在大壓力下很少影響性能。並且運行要求低,只要通過Telnet或SSH等方式遠程登錄到服務器所在機器,就可以進行監控。在與Jmap、JStack等工具結合使用時非常方便。
使用jstat命令監測如下內存使用和垃圾回收統計數據:
$ <JDK>/bin/jstat –gcutil [-h<lines>] <pid> <interval>
jstat - gcutil選項打印所運行應用程序進程ID <pid>在指定抽樣間隔<interval>下,堆使用及垃圾回收時間摘要,並且每<lines>行顯示一次頭信息。這產生出以下樣例輸出:
S0 S1 E O P YGC YGCT FGC FGCT GCT
0.00 0.00 24.48 46.60 90.24 142 0.530 104 28.739 29.269
0.00 0.00 2.38 51.08 90.24 144 0.536 106 29.280 29.816
0.00 0.00 36.52 51.08 90.24 144 0.536 106 29.280 29.816
0.00 26.62 36.12 51.12 90.24 145 0.538 107 29.552 30.090
名列含義:
S0:Survivor space 0 utilization as a percentage of the space's current capacity.
S1:Survivor space 1 utilization as a percentage of the space's current capacity.
E: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.
P:Permanent space utilization as a percentage of the space's current capacity.
YGC:Number of young generation GC events.
YGCT:Young generation garbage collection time.
FGC:Number of full GC events.
FGCT:Full garbage collection time.
GCT:Total garbage collection time.
參考資料:http://java.sun.com/javase/6/docs/technotes/tools/share/jstat.html
轉自 :http://ruijunsuo.blog.163.com/blog/static/4005963220100597723/