实践JDK内置命令之jstat

jstat命令用来查看跟JVM gc相关的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ 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.
1
2
3
4
5
6
7
8
9
10
11
12
13
$ jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcpermcapacity
-gcutil
-printcompilation
1
2
3
4
5
6
7
$ jstat -gcutil 9420 1000 5
  S0     S1     E      O      P     YGC     YGCT    FGC    FGCT     GCT   
  0.09   0.00  44.11  47.13  99.56     30    2.311     0    0.000    2.311
  0.09   0.00  44.11  47.13  99.56     30    2.311     0    0.000    2.311
  0.09   0.00  44.11  47.13  99.56     30    2.311     0    0.000    2.311
  0.09   0.00  44.11  47.13  99.56     30    2.311     0    0.000    2.311
  0.09   0.00  44.11  47.13  99.56     30    2.311     0    0.000    2.311

G1

1
2
3
$ jstat -gcutil 26493
  S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
  0.00 100.00  31.75   2.06  96.74  95.32      7    0.262     0    0.000    0.262
1
2
3
4
5
6
$ jstat -gc 26493 2s 3
 S0C    S1C    S0U    S1U      EC       EU        OC         OU       MC     MU    CCSC   CCSU   YGC     YGCT    FGC    FGCT     GCT   
 0.0   34816.0  0.0   34816.0 516096.0 163840.0  497664.0   10240.0   69504.0 67241.3 8576.0 8174.6      7    0.262   0      0.000    0.262
 0.0   34816.0  0.0   34816.0 516096.0 163840.0  497664.0   10240.0   69504.0 67241.3 8576.0 8174.6      7    0.262   0      0.000    0.262
 0.0   34816.0  0.0   34816.0 516096.0 163840.0  497664.0   10240.0   69504.0 67241.3 8576.0 8174.6      7    0.262   0      0.000    0.262
[industry@ind-sit-1 industry-boss]$