Jstat command (Java Virtual machine Statistics monitoring Tool)

Source: Internet
Author: User

1. Introduction

Jstat is used to monitor the hotspot-based JVM for real-time command-line statistics on the use of its heap, and with jstat we can monitor the specified JVM as follows:

-Loading and unloading of classes

-View capacity and usage of new generation, Laosheng generation and durable generation

-View the new generation, Laosheng generation and durable generation of garbage collection, including the number of garbage collected and the time taken by garbage collection

-View the capacity and distribution of the new generation in Eden and Survior areas, etc.

The Jstat tool is particularly powerful and has a multitude of options, allowing us to understand the current JVM heap usage from different dimensions by providing a variety of different monitoring dimensions. View the usage of each part of the heap in detail, using the Java process number to be counted, the different dimension parameters, and optional statistical frequency parameters.

It is mainly used to display GC and PermGen related information, if the GC does not understand, first read this article: Http://blog.csdn.net/fenglibing/archive/2011/04/13/6321453.aspx, Otherwise, even if you use the Jstat command, you can't read its output.

2. Grammar

Jstat [generaloption | outputoptions vmid [INTERVAL[S|MS] [count]]

generaloption -a single common command-line option, such as-help,-options, or-version.

Outputoptions- One or more output options, consisting of a single statoption option, can be used with options such as-T,-H, and-j, and so on.

statoption:

Depending on the dimensions of the jstat statistic, you can use the options in the following table to make statistics for different dimensions, the options supported by different operating systems may vary, and you can view the options supported by different operating systems through the-options option, such as:

...
Option Displays
Class Statistics for viewing class load conditions
Compiler Statistics to view the compilation of instant compilers in the hotspot
Gc Statistics for viewing garbage collection of heaps in the JVM
Gccapacity For viewing the storage capacity of the Cenozoic, Laosheng generation and durable generations
Gccause Used to view the statistics of garbage collection (this is the same as the-gcutil option), and if garbage collection occurs, it also shows the reason for the last and current garbage collection.
Gcnew For viewing new generation garbage collection scenarios
Gcnewcapacity For viewing the storage capacity of the Cenozoic
Gcold Used to view Laosheng generation and persistent generation of GC
Gcoldcapacity Used to view the capacity of the Laosheng generation
Gcpermcapacity Used to view the capacity of a durable generation
Gcutil For viewing new generation, Laosheng generation and generation garbage collection
Printcompilation Statistics of the Hotspot compilation method

- h N

Used to specify the output column header every few lines, if not specified, the default is only the column header appears in the first row.

-jjavaoption

Used to pass the given javaoption to the Java application loader, for example, "-j-xms48m" will set the boot memory to 48M. If you want to see which options can be passed to the application loader, you can tearful the following documents:

Linux and Solaris:http://docs.oracle.com/javase/1.5.0/docs/tooldocs/solaris/java.html

Windows:http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/java.html

- t N

Used to display the timestamp in the first column of the output, which represents the time when the JVM started to start to the present (note: This option is not available in IBM JDK5).

Vmid -The process number of the VM, which is the currently running Java process number.

There are also two options for display frequency:

Interval– The interval, in seconds or milliseconds, determined by specifying s or MS, which is the default unit of milliseconds.

Count-The number of prints, if the default is printed countless times.

3. Different statistical dimensions (statoption) and output instructions

-class
Statistics for class load cases
Column Name Description
Loaded The number of classes loaded
Bytes The size of the loaded class, single-kb
Unloaded The number of classes that were unloaded
Bytes The size of the unloaded class, single-kb
Time Time spent loading and unloading classes
-compiler
Statistics on the compilation of instant compilers in the hotspot
Column Name Description
Compiled Number of compile task executions
Failed Number of failed compile task executions
Invalid Number of illegal compile task executions
Time The time it took to execute the compilation
Failedtype Compilation type of the last compilation failure
Failedmethod Class name and method name for the last compilation failure
-gc
statistics on garbage collection of heaps in the JVM
Column Name Description
s0c The size of S0 current capacity in Survivor space in the Cenozoic (KB)
S1c The size of S1 current capacity in Survivor space in the Cenozoic (KB)
s0u S0 capacity usage in survivor space in the Cenozoic (KB)
s1u S1 capacity usage in survivor space in the Cenozoic (KB)
EC Eden Space Current capacity size (KB)
EU Eden Space capacity usage size (KB)
Oc Old space Current capacity size (KB)
OU Old space uses the size of the capacity (KB)
Pc Permanent Space Current capacity size (KB)
Pu Size of Permanent space using capacity (KB)
Ygc Number of young GC occurrences from application startup to sampling
Ygct The time (in seconds) that the young GC took from the application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
Fgct The time (in seconds) spent in full GC from application startup to sampling
GCT T total time (in seconds) for garbage collection from application startup to sampling, and its value equals YGC+FGC
-gccapacity
the storage capacity of Cenozoic, Laosheng generation and persistent generations
Column Name Description
Ngcmn Minimum capacity size of the Cenozoic (KB)
Ngcmx Maximum capacity size of the Cenozoic (KB)
Ngc Current generation capacity size (KB)
s0c Capacity size of Survivor space 0 in the current Cenozoic (KB)
S1c Capacity size of Survivor space 1 in the current Cenozoic (KB)
EC Eden Space Current capacity size (KB)
Ogcmn Minimum capacity size of Laosheng (KB)
Ogcmx Maximum capacity size of the Laosheng generation (KB)
OGC Capacity size of current Laosheng generation (KB)
Oc The current Laosheng generation's space capacity size (KB)
Pgcmn Minimum capacity size for persistent generations (KB)
Pgcmx Maximum capacity size for durable generations (KB)
Pgc Capacity size of the current durable Generation (KB)
Pc Current persistent generation space capacity size (KB)
Ygc Number of young GC occurrences from application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
-gccause

This option is used to view garbage collection statistics (this is the same as the-gcutil option), and if garbage collection occurs, it also shows the reason for the last and currently occurring garbage collection, which is more than -gcutil The reason for the last garbage collection and the garbage collection that is currently occurring are more than one.

Used to view the statistics of garbage collection, including the cause of recent garbage occurrences
Column Name Description
lgcc The reason for the last garbage collection may be "Unknown gccause", "System.GC ()", etc.
Gcc Reasons for the current garbage collection
-gcnew
the situation of new generation garbage collection
Column Name Description
s0c Capacity size of Survivor space 0 in the current Cenozoic (KB)
S1c Capacity size of Survivor space 1 in the current Cenozoic (KB)
s0u S0 already used size (KB)
s1u S1 already used size (KB)
Tt Tenuring threshold, to understand this parameter, we need to understand the structure of a bit of Java memory objects, in the Sun JVM, objects (except for arrays) have two machine word (words) headers. The first word contains the hash code of the object and some other similar lock status and other identifying information, and the second word contains a reference to the object's class, where the second byte is used by the garbage collection algorithm.
When doing garbage collection in the Cenozoic, each time an object is copied, it will increase the collection count of this object, when an object is duplicated in the Cenozoic a certain number of times, the algorithm is determined that the object is a long period of the object, moving him to Laosheng generation, the threshold is called tenuring threshold. This threshold is used to denote an object that is still alive after the number of YOUNGGC has been executed, even if the newborn survior is not full, and is also considered a long-period object, and will be moved to the Laosheng generation.
Mtt Maximum tenuring threshold, used to represent the maximum value of the TT.
Dss Desired survivor Size (KB). Can participate here: http://blog.csdn.net/yangjun2/article/details/6542357
EC Eden Space Current capacity size (KB)
EU The size of Eden space already used (KB)
Ygc Number of young GC occurrences from application startup to sampling
Ygct The time (in seconds) that the young GC took from the application startup to sampling
-gcnewcapacity
the storage capacity of the new generation
Column Name Description
Ngcmn Minimum capacity size of the Cenozoic (KB)
Ngcmx Maximum capacity size of the Cenozoic (KB)
Ngc Current generation capacity size (KB)
S0cmx Max capacity size of so in Cenozoic (KB)
s0c The capacity size of so in the current Cenozoic (KB)
S1cmx Maximum capacity size of S1 in Cenozoic (KB)
S1c Capacity size of S1 in current Cenozoic (KB)
ecmx < Span style= "font-family: the song Body;" >
EC Capacity size of Eden in the current Cenozoic (KB)
Ygc Number of young GC occurrences from application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
-gcold
Laosheng generation and persistent generation of GC cases
Column Name Description
Pc Size of current persistent generation capacity (KB)
Pu Size of persistent usage capacity (KB)
Oc Size of the current old age volume (KB)
OU Old age Use the size of the volume (KB)
Ygc Number of young GC occurrences from application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
Fgct Time spent in full GC from application startup to sampling (in seconds)
GCT Total time (in seconds) for garbage collection from application startup to sampling, with a value equal to YGC+FGC
-gcoldcapacity
storage capacity of the Laosheng generation
Column Name Description
Ogcmn Minimum capacity size of Laosheng (KB)
Ogcmx Maximum capacity size of the Laosheng generation (KB)
OGC Capacity size of current Laosheng generation (KB)
Oc Current Cenozoic space capacity size (KB)
Ygc Number of young GC occurrences from application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
Fgct Time spent in full GC from application startup to sampling (in seconds)
GCT Total time (in seconds) for garbage collection from application startup to sampling, with a value equal to YGC+FGC
-gcpermcapacity

Number of full GC occurrences from application startup to sampling

storage capacity for persistent generations
Column Name Description
Pgcmn Minimum capacity size for persistent generations (KB)
Pgcmx Maximum capacity size for durable generations (KB)
Pgc the capacity size of the current persistent generation ( KB)
Pc The space capacity size of the current durable generation ( KB)
Ygc Number of young GC occurrences from application startup to sampling
FGC
Fgct Time spent in full GC from application startup to sampling (in seconds)
GCT Total time (in seconds) for garbage collection from application startup to sampling, with a value equal to YGC+FGC
-gcutil
The situation of generation, Laosheng generation and garbage collection
Column Name Description
S0 Percentage of space used in Survivor space zone 0 on the heap
S1 Percentage of space used in Survivor space Zone 1 on the heap
E Percentage of space used in Eden space on the heap
O The percentage of space used in the old area on the heap
P Percentage of space already used in the Perm space area
Ygc Number of young GC occurrences from application startup to sampling
Ygct The time (in seconds) that the young GC took from the application startup to sampling
FGC Number of full GC occurrences from application startup to sampling
Fgct Time spent in full GC from application startup to sampling (in seconds)
GCT Total time (in seconds) for garbage collection from application startup to sampling, with a value equal to YGC+FGC
-printcompilation
Statistics of the Hotspot compilation method
Column Name Description
Compiled Number of compile task executions
Size The number of bytes of the method's byte code
Type Compilation type
Method Specifies the class name and method name that determines the method being compiled, with the name "/" instead of "." In the class name. As a named delimiter, the method name is a method in the specified class, and the format of the two fields is determined by the "-xx:+printcomplation" option in the hotspot.



4. Examples of Use

Example 1),

Example 2):

The total number of times for both the young GC and the full GC is printed at the same time. And, each time that the young GC consumes, it can be subtracted from two lines of YGCT in the phase interval. Each time the full GC is consumed, it can be subtracted from two lines fgct apart. For example, the first row represented in the red box and the second row occurred 1 times with the young GC, which consumed a time of 0.252-0.252=0.0 seconds.

Resident Memory Area (P) usage, always stay around 64.21%, indicating that resident memory does not mutate, more normal. If both the young GC and the full GC can occur properly, and both can effectively reclaim memory, the resident memory area is not significantly changed, then the Java memory release is normal, garbage collection is timely, the chance of Java memory leakage will be greatly reduced. But it does not necessarily indicate that there is no memory leak.

Example 3),

Above, this article describes the function of Jstat to view GC status by percentage. In fact, it also has functions, such as load class information statistics function, memory pool information statistics function, those are in the form of absolute value printed out, less use, do not introduce here.

Example 4), Jstat-class PID: Displays information such as the number of loaded classes, and the amount of space occupied.

Example 5), Jstat-compiler PID: Displays information such as the number of real-time VMS compiled.

Example 6), view the GC situation on the remote server.

This needs to start on the remote server above the JSTATD service, you can choose to see how to open jstatd service here, http://blog.csdn.net/fenglibing/article/details/17323515

Here is an example of execution:

C:\Documents and Settings\administrator>jstat-gcutil [email protected]_ip:2021/jstatdname 1000

S0 S1 E O P ygc ygct FGC fgct GCT
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000
0.00 0.00 8.00 0.00 24.36 0 0.000 0 0.000 0.000

Examples are not one by one cases, interested can try it yourself.


Instructions for using Jstat on Oracle: http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html

Jstat command (Java Virtual machine Statistics monitoring Tool)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.