jstat命令

Jstat是JDK自带的一个轻量级小工具。全称“Java Virtual Machine statistics monitoring tool”,它位于java的bin目录下,主要利用JVM内建的指令对Java应用程序的资源和性能进行实时的命令行的监控,包括了对  Heap size和垃圾回收状况的监控
 

语法结构:

Usage: jstat -help|-options

       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

 参数解释:

Options — 选项,我们一般使用 -gcutil 查看gc情况

vmid    — VM的进程号,即当前运行的java进程号

interval– 间隔时间,单位为秒或者毫秒

count   — 打印次数,如果缺省则打印无数次

 

S0  — Heap上的 Survivor space 0 区已使用空间的百分比
S1  — Heap上的 Survivor space 1 区已使用空间的百分比
E   — Heap上的 Eden space 区已使用空间的百分比
O   — Heap上的 Old space 区已使用空间的百分比
P   — Perm space 区已使用空间的百分比
YGC — 从应用程序启动到采样时发生 Young GC 的次数
YGCT– 从应用程序启动到采样时 Young GC 所用的时间(单位秒)
FGC — 从应用程序启动到采样时发生 Full GC 的次数
FGCT– 从应用程序启动到采样时 Full GC 所用的时间(单位秒)
GCT — 从应用程序启动到采样时用于垃圾回收的总时间(单位秒)

 

常用命令:

 jstat -gcutil java进程号 时间间隔 次数

 S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT

 73.54   0.00  99.04  67.52  98.49    166    0.252     6    0.331    0.583

 73.54   0.00  99.04  67.52  98.49    166    0.252     6    0.331    0.583

 73.54   0.00  99.04  67.52  98.49    166    0.252     6    0.331    0.583

 73.54   0.00  99.04  67.52  98.49    166    0.252     6    0.331    0.583

 73.54   0.00  99.04  67.52  98.49    166    0.252     6    0.331    0.583

 

jstat –gccapacity :可以显示,VM内存中三代(young,old,perm)对象的使用和占用大小

[root@localhost bin]# jstat -gccapacity pid

 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC      PGCMN    PGCMX     PGC       PC     YGC    FGC 

524288.0 524288.0 524288.0 54592.0 52096.0 417600.0  1572864.0  1572864.0  1572864.0  1572864.0 131072.0 262144.0 173120.0 173120.0     26     1

 

NGCMNMinimum new generation capacity (KB).
NGCMXMaximum new generation capacity (KB).
NGCCurrent new generation capacity (KB).
S0CCurrent survivor space 0 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
ECCurrent eden space capacity (KB).
OGCMNMinimum old generation capacity (KB).
OGCMXMaximum old generation capacity (KB).
OGCCurrent old generation capacity (KB).
OCCurrent old space capacity (KB).
PGCMNMinimum permanent generation capacity (KB).
PGCMXMaximum Permanent generation capacity (KB).
PGCCurrent Permanent generation capacity (KB).
PCCurrent Permanent space capacity (KB).
YGCNumber of Young generation GC Events.
FGCNumber of Full GC Events.

 

jstat -class pid:显示加载class的数量,及所占空间等信息。

实例使用3:

[root@localhost bin]# jstat -class 25917

Loaded  Bytes  Unloaded  Bytes     Time

2629    2916.8       29   24.6     0.90

 

jstat -compiler pid:显示VM实时编译的数量等信息。

实例使用4:

[root@localhost bin]# jstat -compiler 25917

Compiled Failed Invalid   Time   FailedType FailedMethod

     768      0       0   0.70            0

 

jstat -gcnew pid: new对象的信息

[root@localhost bin]# jstat -gcnew 25917

 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU        YGC     YGCT

 64.0    64.0    47.4    0.0     2  15     32.0       704.0    145.7    168    0.254

S0CCurrent survivor space 0 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
S0USurvivor space 0 utilization (KB).
S1USurvivor space 1 utilization (KB).
TTTenuring threshold.
MTTMaximum tenuring threshold.
DSSDesired survivor size (KB).
ECCurrent eden space capacity (KB).
EUEden space utilization (KB).
YGCNumber of young generation GC events.
YGCTYoung generation garbage collection time.

 

jstat -gcnewcapacity pid: new对象的信息及其占用量

[root@localhost bin]# jstat -gcnewcapacity 25917

 NGCMN  NGCMX   NGC   S0CMX  S0C   S1CMX  S1C   ECMX    EC      YGC   FGC

640.0       4992.0    832.0   64.0       448.0 448.0     64.0   4096.0  704.0  168     6

NGCMN           Minimum new generation capacity (KB). 
NGCMX    Maximum new generation capacity (KB).
NGC    Current new generation capacity (KB).
S0CMXMaximum survivor space 0 capacity (KB).
S0CCurrent survivor space 0 capacity (KB).
S1CMXMaximum survivor space 1 capacity (KB).
S1CCurrent survivor space 1 capacity (KB).
ECMXMaximum eden space capacity (KB).
ECCurrent eden space capacity (KB).
YGCNumber of young generation GC events.
FGCNumber of Full GC Events.

 

jstat -gcold pid: old对象的信息。

[root@localhost bin]# jstat -gcold 25917

   PC       PU        OC          OU       YGC    FGC    FGCT     GCT

 12800.0  12617.6     9504.0      6561.3   169     6    0.335    0.591

 

jstat -gcoldcapacity pid:old对象的信息及其占用量。

[root@localhost bin]# jstat -gcoldcapacity 25917

OGCMN      OGCMX        OGC         OC       YGC   FGC    FGCT     GCT

1408.0     60544.0      9504.0      9504.0   169     6    0.335    0.591

 

jstat -gcpermcapacity pid: perm对象的信息及其占用量。

[root@localhost bin]# jstat -gcpermcapacity 25917

PGCMN      PGCMX       PGC         PC      YGC   FGC    FGCT     GCT

8192.0    65536.0    12800.0    12800.0   169     6    0.335    0.591

 

jstat -printcompilation pid:当前VM执行的信息。

[root@localhost bin]# jstat -printcompilation -h3  25917 1000 5

每1000毫秒打印一次,一共打印5次,还可以加上-h3每三行显示一下标题。

Compiled  Size  Type Method

     788     73    1 java/io/File <init>

     788     73    1 java/io/File <init>

     788     73    1 java/io/File <init>

Compiled  Size  Type Method

     788     73    1 java/io/File <init>

     788     73    1 java/io/File <init>

 

-gcpermcapacity Option

Permanent Generation Statistics
ColumnDescription
PGCMNMinimum permanent generation capacity (KB).
PGCMXMaximum permanent generation capacity (KB).
PGCCurrent permanent generation capacity (KB).
PCCurrent permanent space capacity (KB).
YGCNumber of young generation GC events.
FGCNumber of full GC events.
FGCTFull garbage collection time.
GCTTotal garbage collection time.
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值