has been using Jconsole to monitor the JVM, the graphical interface is easy to use, recently because the need to operate under the pure Linux, so summed up the Linux monitoring JVM under the example, this time the main use of the Jstat tool,
The meaning of each parameter:
Jstat-class PID: Displays the number of loaded classes, and the amount of space that is occupied.
Jstat-compiler PID: Displays information such as the number of real-time VMS compiled.
JSTAT-GC PID: can display GC information, view GC number of times, and time. The last five items were the number of young GC, the time of young GC, the number of full GC, the time of full GC, and the total time of GC.
Jstat-gccapacity: It can be shown that the use and occupancy of three generation (Young,old,perm) objects in VM memory, such as: PGCMN shows the minimum perm memory usage, PGCMX shows the maximum amount of memory used for Perm, The PGC is the current newly generated perm memory footprint, and the PC is but the pre-perm memory footprint. The other can be based on this analogy, OC is the old inside the pure consumption.
Jstat-gcnew the information for the Pid:new object.
Jstat-gcnewcapacity the information of the Pid:new object and its consumption.
Jstat-gcold the information for the Pid:old object.
Jstat-gcoldcapacity the information of the Pid:old object and its consumption.
Jstat-gcpermcapacity the information of the Pid:perm object and its consumption.
Jstat-util PID: Statistical GC information statistics.
Jstat-printcompilation PID: Information for the current VM execution.
In addition to one of the above parameters, you can also add two numbers at the same time, such as: Jstat-printcompilation 3024 250 6 is printed every 250 milliseconds, a total of 6 times, you can add-h3 every three lines to display the title.
Syntax structure:
Usage:jstat-help|-options
Jstat-<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]
Parameter explanation:
options-option, we generally use-gcutil to view GC conditions
The VMID-VM process number, which is the currently running Java process number
interval– interval time, in seconds or milliseconds
count-printing times, if the default is printed countless times
Percentage of space used in Survivor space zone 0 on S0-heap
Percentage of space used in Survivor space Zone 1 on S1-heap
Percentage of space used in Eden space on E-heap
The percentage of space used in the old area on the O-heap
Percentage of space already used in the P-perm space area
ygc-number of young GC occurrences from application boot to sample
ygct– the time (in seconds) used by the young GC when booting from the application to sampling
fgc-the number of full GC occurrences from application startup to sampling
fgct– time (in seconds) for full GC from application boot to sampling
gct-total time (in seconds) for garbage collection from application startup to sampling
Instance using 1:
[Email protected] bin]# Jstat-gcutil 25444
S0 S1 E O P ygc ygct FGC fgct GCT
11.63 0.00 56.46 66.92 98.49 162 0.248 6 0.331 0.579
Instance using 2: (25444 is the Java process number, PS-EF | grep java)
[Email protected] bin]# Jstat-gcutil 25444 1000 5
S0 S1 E O P ygc ygct FGC fgct GCT
73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583
73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583
73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583
73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583
73.54 0.00 99.04 67.52 98.49 166 0.252 6 0.331 0.583
As we can see, 5 times after the young GC, the garbage memory was put into the old space (O) from the Eden Space (E) and caused a change in percentage, causing the percentage of survivor space to be reduced from 73.54% (S0) to 0% (S1). Effectively frees up memory space. Green box, we can see that after a full GC, the memory of the old Space Area (O) is recycled from 99.05% to 67.52%.
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 98.49%, 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.
GCT is the sum of time for YGCT and FGCT.
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.
[Email protected] bin]# Ps-ef | grep java
Root 25917 1 2 23:23 pts/2 00:00:05/usr/local/jdk1.5/bin/java-djava.endorsed.dirs=/usr/local/jakarta-tomcat-5.0.30/ common/endorsed-classpath/usr/local/jdk1.5/lib/tools.jar:/usr/local/jakarta-tomcat-5.0.30/bin/bootstrap.jar:/ usr/local/jakarta-tomcat-5.0.30/bin/commons-logging-api.jar-dcatalina.base=/usr/local/jakarta-tomcat-5.0.30- Dcatalina.home=/usr/local/jakarta-tomcat-5.0.30-djava.io.tmpdir=/usr/local/jakarta-tomcat-5.0.30/temp Org.apache.catalina.startup.Bootstrap start
Jstat-class PID: Displays the number of loaded classes, and the amount of space that is occupied.
Instance using 3:
[Email protected] bin]# Jstat-class 25917
Loaded Bytes Unloaded Bytes time
2629 2916.8 29) 24.6 0.90
Jstat-compiler PID: Displays information such as the number of real-time VMS compiled.
Instance using 4:
[Email protected] bin]# Jstat-compiler 25917
Compiled Failed Invalid Time Failedtype Failedmethod
768 0 0) 0.70 0
Jstat–gccapacity: It can be shown that the use and occupancy of three generation (Young,old,perm) objects in VM memory, such as: PGCMN shows the minimum perm memory usage, PGCMX shows the maximum amount of memory used for Perm, The PGC is the current newly generated perm memory footprint, and the PC is but the pre-perm memory footprint. The other can be based on this analogy, OC is the old inside the pure consumption.
[Email protected] bin]# jstat-gccapacity 25917
NGCMN 640.0
NGCMX 4992.0
NGC 832.0
s0c 64.0
S1c 64.0
EC 704.0
OGCMN 1408.0
OGCMX 60544.0
OGC 9504.0
OC 9504.0 OC is pure consumption in old
PGCMN 8192.0 PGCMN shows the minimum perm memory usage
PGCMX 65536.0 PGCMX shows the maximum amount of memory used for Perm
PGC 12800.0 PGC is the current newly generated perm memory footprint
PC 12800.0 pc Yes but front perm memory consumption
YGC 164
FGC 6
Jstat-gcnew Information for Pid:new objects
[Email protected] bin]# jstat-gcnew 25917
s0c s1c s0u s1u TT MTT DSS EC EU YGC YGCT
64.0 64.0 47.4 0.0 2 15 32.0 704.0 145.7 168 0.254
Jstat-gcnewcapacity information of Pid:new objects and their consumption
[Email protected] bin]# jstat-gcnewcapacity 25917
NGCMN ngcmx NGC s0cmx s0c s1cmx s1c ecmx EC YGC FGC
640.0 4992.0 832.0 64.0 448.0 448.0 64.0 4096.0 704.0 168 6
Jstat-gcold the information for the Pid:old object.
[Email protected] bin]# Jstat-gcold 25917
PC PU OC OU ygc FGC fgct GCT
12800.0 12617.6 9504.0 6561.3 169 6 0.335 0.591
Jstat-gcoldcapacity the information of the Pid:old object and its consumption.
[Email protected] bin]# jstat-gcoldcapacity 25917
OGCMN ogcmx OGC OC ygc FGC fgct GCT
1408.0 60544.0 9504.0 9504.0 169 6 0.335 0.591
Jstat-gcpermcapacity the information of the Pid:perm object and its consumption.
[Email protected] bin]# jstat-gcpermcapacity 25917
PGCMN pgcmx PGC PC ygc FGC fgct GCT
8192.0 65536.0 12800.0 12800.0 169 6 0.335 0.591
Jstat-printcompilation PID: Information for the current VM execution.
[Email protected] bin]# JSTAT-PRINTCOMPILATION-H3 25917 1000 5
Print every 1000 milliseconds, print 5 times, and add-h3 every three lines to show the title.
Compiled Size Type Method
788 1 Java/io/file <init>
788 1 Java/io/file <init>
788 1 Java/io/file <init>
Compiled Size Type Method
788 1 Java/io/file <init>
788 1 Java/io/file <init>
How to monitor JVM usage under Linux