Java Virtual Machine statistics monitoring tool
主要利用 JVM 内建的指令对 Java 应用程序的资源和性能进行实时的命令行的监控,包括了对 Heap size 和垃圾回收状况的监控。
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.
jstat -options
-class
-compiler
-gc
-gccapacity
-gccause
-gcmetacapacity
-gcnew
-gcnewcapacity
-gcold
-gcoldcapacity
-gcutil
-printcompilation
option 可以从下面参数中选择
显示加载class的数量,及所占空间等信息。
PWD:workspace pwd$ jstat -class 21668
Loaded Bytes Unloaded Bytes Time
10614 18813.4 1 0.9 4.60
显示JIT编译的相关信息。
PWD:workspace pwd$ jstat -compiler 21668
Compiled Failed Invalid Time FailedType FailedMethod
5461 0 0 1.67 0
显示和gc相关的堆信息
PWD:workspace pwd$ jstat -gc 21668
S0C S1C S0U S1U EC EU OC OU MC MU CCSC CCSU YGC YGCT FGC FGCT GCT
18432.0 21504.0 18405.7 0.0 288768.0 70018.3 163840.0 23706.4 51200.0 48643.2 7168.0 6648.7 10 0.087 2 0.071 0.158
显示各个代的容量以及使用情况,VM内存中三代(young,old,perm)对象的使用和占用大小
PWD:workspace pwd$ jstat -gccapacity 21668
NGCMN NGCMX NGC S0C S1C EC OGCMN OGCMX OGC OC MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC
87040.0 1397760.0 344576.0 18432.0 21504.0 288768.0 175104.0 2796544.0 163840.0 163840.0 0.0 1093632.0 51200.0 0.0 1048576.0 7168.0 10 2
显示metaspace的大小
PWD:workspace pwd$ jstat -gcmetacapacity 21668
MCMN MCMX MC CCSMN CCSMX CCSC YGC FGC FGCT GCT
0.0 1093632.0 51200.0 0.0 1048576.0 7168.0 10 2 0.071 0.158
显示新生代信息
PWD:workspace pwd$ jstat -gcnew 21668
S0C S1C S0U S1U TT MTT DSS EC EU YGC YGCT
18432.0 21504.0 18405.7 0.0 3 15 21504.0 288768.0 70018.3 10 0.087
显示新生代大小和使用情况
PWD:workspace pwd$ jstat -gcnewcapacity 21668
NGCMN NGCMX NGC S0CMX S0C S1CMX S1C ECMX EC YGC FGC
87040.0 1397760.0 344576.0 465920.0 18432.0 465920.0 21504.0 1396736.0 288768.0 10 2
显示老年代和永久代的信息
PWD:workspace pwd$ jstat -gcold 21668
MC MU CCSC CCSU OC OU YGC FGC FGCT GCT
51200.0 48643.2 7168.0 6648.7 163840.0 23706.4 10 2 0.071 0.158
显示老年代的大小
PWD:workspace pwd$ jstat -gcoldcapacity 21668
OGCMN OGCMX OGC OC YGC FGC FGCT GCT
175104.0 2796544.0 163840.0 163840.0 10 2 0.071 0.158
显示垃圾收集信息
PWD:workspace pwd$ jstat -gcutil 21668
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT
99.86 0.00 24.25 14.47 95.01 92.76 10 0.087 2 0.071 0.158
显示垃圾回收的相关信息(通-gcutil),同时显示最后一次或当前正在发生的垃圾回收的诱因
S0 S1 E O M CCS YGC YGCT FGC FGCT GCT LGCC GCC
99.86 0.00 24.25 14.47 95.01 92.76 10 0.087 2 0.071 0.158 Allocation Failure No GC
输出JIT编译的方法信息
Compiled Size Type Method
5466 41 1 java/text/DecimalFormat getPositiveSuffixFieldPositions

