Java虚拟机的统计监测工具:jstat

jstat:是JDK自带的虚拟机统计监测工具
在命令行中执行jstat

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.

通过不的option可以查看JVM当前的各种信息,比如:类, 内存等
参数主要有:

  • class: 类装载器统计
  • compiler: HotSpot JVM实时编译统计
  • gc: 垃圾回收堆统计
  • gccapacity: 内存统计
  • gccause: 垃圾回收统计信息,包括回收事件
  • gcnew: 对象创建情况
  • gcnewcapacity: 对象创建内存情况
  • gcold: 老年代和永久代统计
  • gcoldcapacity: 老年代统计
  • gcpermcapacity: 永久代统计
  • gcutil: 垃圾收集的统计
  • printcompilation: HotSpot编译器的方法统计

执行: jstat -class 2000 结果如下

加载类的个数 加载类的大小 卸载类的个数 卸载类的大小 加载和卸载所占用的时间
Loaded Bytes Unloaded Bytes Time
23624 29798.8 1346 1225.8 218.34

执行: jstat -compiler 2000 结果如下

编译的个数 编译失败的个数 无效的编译个数 编译所用时间 最后一次编译失败的类型 最后一次编译失败的方法
Compiled Failed Invalid Time FailedType FailedMethod
1629 1 0 0.86 1 org/springframework/asm/ClassReader accept

执行: jstat -gc 2000 结果如下

Permanent

使用大小

Survivor 0的大小(KB) Survivor 1的大小(KB) Survivor 0使用大小 Survivor 1使用大小 Eden大小 Eden使用大小 Old大小 Old使用大小 Permanent大小 Young generation GC次数 Young generation GC时间 Full GC次数 Full GC时间 所有GC时间
S0C S1C S0U S1U EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
14016.0 14016.0 2932.5 0.0 112192.0 96465.9 280212.0 227679.0 116480.0 116338.6 418 37.823 34 59.928 97.751

执行: jstat -gccapacity 2000 结果如下

新生代最小 新生代最大 当前新生代(NGC=S0C+S1C+EC) Survivor 0大小 Survivor 1大小 Eden大小 老年代最小 老年代最大 老年代当前大小 老年代当前容量 永久代最小 永久代最大 当前永久代大小 永久代容量 Young GC次数 Full GC次数
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC PGCMN PGCMX PGC PC YGC FGC
13632.0 174720.0 140224.0 14016.0 14016.0 112192.0 27328.0 349568.0 280212.0 280212.0 12288.0 262144.0 116480.0 116480.0 419 34

执行: jstat -gccause 2000 结果如下

Survivor 0使用率 Survivor 1使用率 Eden使用率 Old使用率 Permanent使用率 YoungGC次数 YoungGC时间 FullGC次数 FullGC时间 GC总时间 上一次GC原因 当前GC原因
S0 S1 E O P YGC YGCT FGC FGCT GCT LGCC GCC
0.00 21.85 20.68 81.25 99.88 419 37.836 34 59.928 97.764 unknown GCCause No GC

执行: jstat -printcompilation 2000 结果如下

编译次数 方法的字节码的字节数 编译类型 编译方法
Compiled Size Type Method
13575 17 1 org/eclipse/swt/widgets/Caret hasFocus

猜你喜欢

转载自ligaosong.iteye.com/blog/1702794
今日推荐