jstat 初探

本文详细介绍jstat工具的使用方法,包括如何查看JVM的类装载、垃圾收集和JIT编译信息。通过具体示例,展示如何监控tomcat进程的JVM状态,如类加载数量、垃圾回收情况和编译信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

jstat 查看JVM统计信息

  • 类装载信息
  • 垃圾收集信息
  • JIT编译信息

命令格式

文档

[root@jvm001 ~]# jstat -help
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.
  • options: -class, -compiler, -gc, -printcompilation

示例

查看tomcat进程的类加载信息
  • Loaded:加载的类的个数;
  • Bytes:加载的类多少个k
  • 1000:每隔多少毫秒显示一次;
  • 10:一共显示几次;
[root@jvm001 ~]# jstat -class 732 
Loaded  Bytes  Unloaded  Bytes     Time   
  2684  5314.3        0     0.0       1.65
[root@jvm001 ~]# jstat -class 732 1000 10
Loaded  Bytes  Unloaded  Bytes     Time   
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
  2684  5314.3        0     0.0       1.65
查看tomcat进程的垃圾收集信息
  • C:capacity;
  • U:used;
  • C和U前面的是每个内存区的编号;
[root@jvm001 ~]# jstat -gc 732 1000 3
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
960.0  960.0   0.0    10.1   7744.0   5197.2   19196.0    14150.8   16768.0 16223.6 1920.0 1814.2     13    0.053   1      0.021    0.074
960.0  960.0   0.0    10.1   7744.0   5197.2   19196.0    14150.8   16768.0 16223.6 1920.0 1814.2     13    0.053   1      0.021    0.074
960.0  960.0   0.0    10.1   7744.0   5282.0   19196.0    14150.8   16768.0 16223.6 1920.0 1814.2     13    0.053   1      0.021    0.074
查看tomcat进程的JIT编译信息
[root@jvm001 ~]# jstat -compiler 732
Compiled Failed Invalid   Time   FailedType FailedMethod
    1776      1       0     3.30          1 org/apache/tomcat/util/IntrospectionUtils setProperty
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值