1. 概述

1.1. 工具简介

jstat(JVM Statistics Monitoring Tool),用于收集Java虚拟机运行时的各方面是数据,该工具可以显示本地或远程虚拟机进程中的类装载、内存、垃圾收集、JIT编译等运行数据,在没有GUI工具的情况下,该工具是运行期定位VM问题的首选工具;

该工具能查询的虚拟机信息包括:

  • 类装载;

1.2. 命令帮助

wanghui@Mokalas-MacBook-Pro ~ $ jstat --help
invalid argument count
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.

其中选项参数为: -h:每打印多少输出一次表头信息;

  • internval:查询时间间隔,单位为毫秒;
  • count:查询次数,如未指定则为无限次查询;
  • -option:用于查询可监测的选项;
    wanghui@Mokalas-MacBook-Pro ~ $ jstat -options
    -class
    -compiler
    -gc
    -gccapacity
    -gccause
    -gcmetacapacity
    -gcnew
    -gcnewcapacity
    -gcold
    -gcoldcapacity
    -gcutil
    -printcompilation
    

    2. jstat常用选项

    2.1. -class

    监视类的装载、卸载数量、总空间以及类装载所耗费的时间

2.2. -gc

监视Java堆的运行状况,包括Eden区、二个Survior区、老年代、永久带等的容量、已用空间、GC合计等信息;

2.3. -gccapacity

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

2.4. -gcutil(最为常用)

监视内容与-gc基本相同,但输出更加关注已使用空间占总空间的百分比

2.5. -gccause

-gcutil功能一致,但会额外输出导致上一次GC产生的原因

2.6. -gcnew

监视新生代GC的状态

2.7. -gcnewcapactiy

监视内容与-gcnew基本相同,但输出更加关注最大、最小空间

2.8. -gcold

监视老年代GC的状况

2.9. -gcoldcapacity

监视内容与-gcold基本相同,输出更加关注使用到的最大、最小空间

2.10. -gcpermcapacity

输出永久带使用的最大、最小空间

2.11. -compiler

输出JIT编译器编译过的方法、耗时等信息

2.12. -printcompilation

输出已经被JIT编译的方法

Copyright © 辉辉大侠@杭州 2017 all right reserved,powered by Gitbook修订时间: 2017-03-30 01:17:50

results matching ""

    No results matching ""