java虚拟机进程状况工具jstat的使用

目录

使用场景说明

查询

第一步:先通过jsp查询虚拟机进程ID

jstat查询虚拟机信息主要有3类:类装载、垃圾收集、运行期编译状况

类装载

垃圾收集相关

运行期编译状况


使用场景说明

jstat(JVM Statistics Monitoring Tool):用于监视虚拟机各种运行状态信息的命令行工具

显示信息:本地获取远程虚拟机进程中的类装载内存、垃圾收集JIT编译等运行数据

适合场景:在纯文本控制台环境上,是运行定位虚拟机性能问题的首选工具

jstat格式jstat 选项 虚拟机进程ID [ [ 间隔时间]   [ 单位秒|毫秒 ]  [ 查询次数 ] ] 

查询

第一步:先通过jps查询虚拟机进程ID

jps -l

查询到正在运行的springboot项目MyTallyApplication虚拟机进程ID=11784 

C:\Users\guangang>jps -l
2224 sun.tools.jps.Jps
28624
28132 org.jetbrains.idea.maven.server.RemoteMavenServer
11784 com.gg.MyTallyApplication
22856 org.jetbrains.jps.cmdline.Launcher

jstat查询虚拟机信息主要有3类:类装载、垃圾收集、运行期编译状况

类装载

jstat -class 11784 250 10

监视类装载、卸载数量、总空间和类装载锁耗费的时间(每250毫秒输出一次,总共输出10次

C:\Users\guangang>jstat -class 11784 250 10
Loaded  Bytes  Unloaded  Bytes     Time
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04
 11966 21580.1        1     0.9       4.04

垃圾收集相关

字符代表的含义列表

E表示Eden
S0、S1表示survivor0和survivor1
O\OLD老年代
PPermanent永久代
YGCMinor GC
FGCFULL GC
FGCTFULL GC耗时

jstat -gc 11784 250 2

监视java堆状况,包括Eden区,survivor区、老年代、永久代、医用空间、GC时间合计等信息

C:\Users\guangang>jstat -gc 11784 250 2
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT
16896.0 20480.0  0.0    0.0   298496.0 38325.2   347648.0   30344.3   59136.0 55938.7 8192.0 7632.8      8    0.058   3      0.217    0.275
16896.0 20480.0  0.0    0.0   298496.0 38325.2   347648.0   30344.3   59136.0 55938.7 8192.0 7632.8      8    0.058   3      0.217    0.275

jstat -gccapacity 11784 250 2

监视内容与-gc基本相同,输出主要关注各个区域使用到的最大、最小空间

C:\Users\guangang>jstat -gccapacity 11784 250 2
 NGCMN    NGCMX     NGC     S0C   S1C       EC      OGCMN      OGCMX       OGC         OC       MCMN     MCMX      MC     CCSMN    CCSMX     CCSC    YGC    FGC
131072.0 2086912.0 364544.0 16896.0 20480.0 298496.0   262144.0  4173824.0   347648.0   347648.0      0.0 1099776.0  59136.0      0.0 1048576.0   8192.0      8     3
131072.0 2086912.0 364544.0 16896.0 20480.0 298496.0   262144.0  4173824.0   347648.0   347648.0      0.0 1099776.0  59136.0      0.0 1048576.0   8192.0      8     3

jstat -gcutil 11784 250 2

已经使用空间和总空间的百分比

C:\Users\guangang>jstat -gcutil 11784 250 2
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT
  0.00   0.00  12.84   8.73  94.59  93.17      8    0.058     3    0.217    0.275
  0.00   0.00  12.84   8.73  94.59  93.17      8    0.058     3    0.217    0.275

jstat -gccause 11784 250 2

与-gcutil基本相同:会输出导致上一次GC产生的原因

C:\Users\guangang>jstat -gccause 11784 250 2
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT    LGCC                 GCC
  0.00   0.00  12.84   8.73  94.59  93.17      8    0.058     3    0.217    0.275 Metadata GC Threshold No GC
  0.00   0.00  12.84   8.73  94.59  93.17      8    0.058     3    0.217    0.275 Metadata GC Threshold No GC

jstat -gcnew 11784 250 2

减产新生代GC情况

C:\Users\guangang>jstat -gcnew 11784 250 2
 S0C    S1C    S0U    S1U   TT MTT  DSS      EC       EU     YGC     YGCT
16896.0 20480.0    0.0    0.0  5  15 20480.0 298496.0  38325.2      8    0.058
16896.0 20480.0    0.0    0.0  5  15 20480.0 298496.0  38325.2      8    0.058

jstat -gcnewcapacity 11784 250 2

与-gcnew基本相同,主要关注最大最小空间

C:\Users\guangang>jstat -gcnewcapacity 11784 250 2
  NGCMN      NGCMX       NGC      S0CMX     S0C     S1CMX     S1C       ECMX        EC      YGC   FGC
  131072.0  2086912.0   364544.0 695296.0  16896.0 695296.0  20480.0  2085888.0   298496.0     8     3
  131072.0  2086912.0   364544.0 695296.0  16896.0 695296.0  20480.0  2085888.0   298496.0     8     3

jstat -gcold 11784 250 2

老年代gc情况

C:\Users\guangang>jstat -gcold 11784 250 2
   MC       MU      CCSC     CCSU       OC          OU       YGC    FGC    FGCT     GCT
 59136.0  55938.7   8192.0   7632.8    347648.0     30344.3      8     3    0.217    0.275
 59136.0  55938.7   8192.0   7632.8    347648.0     30344.3      8     3    0.217    0.275

jstat -gcoldcapacity 11784 250 2

老年代gc情况,主要关注最大最小空间

C:\Users\guangang>jstat -gcoldcapacity 11784 250 2
   OGCMN       OGCMX        OGC         OC       YGC   FGC    FGCT     GCT
   262144.0   4173824.0    347648.0    347648.0     8     3    0.217    0.275
   262144.0   4173824.0    347648.0    347648.0     8     3    0.217    0.275

jstat -gcpermcapacity 11784 250 2

输出永久代最大最小空间,照着书上打的,不晓得为啥没效果了

C:\Users\guangang>jstat -gcpermcapacity 11784 250 2
Unknown option: -gcpermcapacity
Usage: jstat -help|-options
       jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]

Definitions:
  <option>      An option reported by the -options option
  <vmid>        Virtual Machine Identifier. A vmid takes the following form:
                     <lvmid>[@<hostname>[:<port>]]
                Where <lvmid> is the local vm identifier for the target
                Java virtual machine, typically a process id; <hostname> is
                the name of the host running the target Java virtual machine;
                and <port> is the port number for the rmiregistry on the
                target host. See the jvmstat documentation for a more complete
                description of the Virtual Machine Identifier.
  <lines>       Number of samples between header lines.
  <interval>    Sampling interval. The following forms are allowed:
                    <n>["ms"|"s"]
                Where <n> is an integer and the suffix specifies the units as
                milliseconds("ms") or seconds("s"). The default units are "ms".
  <count>       Number of samples to take before terminating.
  -J<flag>      Pass <flag> directly to the runtime system.

运行期编译状况

jstat -compiler 11784 250 2

输出JIT编译器编译过的方法和耗时等细腻

C:\Users\guangang>jstat -compiler 11784 250 2
Compiled Failed Invalid   Time   FailedType FailedMethod
    5537      0       0     1.14          0
    5537      0       0     1.14          0

jstat -printcompilation 11784 250 2

输出已经被jIT编译的方法

C:\Users\guangang>jstat -printcompilation 11784 250 2
Compiled  Size  Type Method
    5538     12    1 java/io/IOException <init>
    5538     12    1 java/io/IOException <init>

 

 

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值