java-jstat Command Detailed
Used to determine if there is a memory problem with the JVM. How to determine if the JVM garbage collection is normal. The general top directive basically doesn't meet this requirement because it mainly monitors the overall system resources and it is difficult to locate Java applications.
Jstat is a lightweight gadget with JDK. The full name "Java Virtual Machine Statistics monitoring Tool", located in the Java Bin directory, uses the JVM-built directives to monitor the resources and performance of Java applications in real time, including the heap Size and the status of garbage collection monitoring. Visible, Jstat is a lightweight, JVM-specific tool that works well. The percentage change in the diagram is less pronounced because the JVM has a large memory setting
A very strong monitoring VM memory tool. can be used to monitor the size and memory usage of various heaps and heaps within the VM's memory.
The Jstat tool is particularly powerful, with numerous options for looking at the amount of usage in each part of the heap and the number of load classes. When used, you need to add the process ID of the view process, and the selected parameters.
Execute: CD $JAVA _home/bin execute jstat, note Jstat must follow the parameters.
Syntax structure:
Usage:jstat-help|-options
Jstat-<option> [t] [-h<lines>] <vmid> [<interval> [<count>]]
Parameter explanation:
options-option, we typically use-gcutil to view GC situations
The VMID-VM process number, which is the currently running Java process number
interval– time interval, in seconds or milliseconds
count-the number of times printed, if the default is printed countless times
S0-heap on Survivor space 0% of the area that has been used
S1-heap on Survivor Space 1% of the area that has been used
Eden area on e-heap percentage of space already used
Percent of space used in old spaces on o-heap
Percentage of space used in P-perm area
ygc-number of young GC occurrences from application startup to sampling
ygct– time (in seconds) for young GC 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 spent in garbage collection from application startup to sampling (in seconds)
Instance use 1:
[Root@localhost 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 uses 2: (25444 is the Java process number, PS-EF | grep java)
[Root@localhost 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
We can see that after 5 young GC, the garbage memory was put into the old space area (O) from the Eden Space Area (E) and caused a percentage change, resulting in the percentage of survivor space being used 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 figure also prints the total number of young GC and full GC, total time consuming. And, each young GC consumes the time, can be separated by two lines of YGCT subtraction. Each time the full GC consumes, it can be subtracted from the two lines of FGCT separated. For example, the first row in the Red box, the second row occurred 1 times young GC, the time spent is 0.252-0.252=0.0 seconds.
Resident Memory Area (P) usage rate, always stay at around 98.49%, indicating resident memory does not mutate, more normal.
If young GC and full GC can occur correctly, and all can effectively reclaim memory, the resident memory area changes are not obvious, it shows that the Java memory release is normal, garbage collection in time, the probability of Java memory leak will be greatly reduced. But it does not necessarily indicate that there is no memory leak.
GCT is the sum of time YGCT and FGCT.
Above, describes the Jstat the GC situation by a percentage of the function. In fact, it also has functions, such as loading class information statistics function, memory pool information statistics, and so on, those are in the form of absolute value printed out, relatively little use, this is not to do introduction.
[Root@localhost 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 to occupy information.
Instance Use 3:
[Root@localhost 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 VM compilations.
Instance use 4:
[Root@localhost bin]# Jstat-compiler 25917
Compiled Failed Invalid Time Failedtype Failedmethod
768 0 0 0.70 0
Jstat–gccapacity: Can show the use and occupancy of three generations (Young,old,perm) objects in VM memory, such as: PGCMN Displays the minimum perm memory usage, PGCMX displays the maximum amount of memory used by Perm. PGC is currently the newly generated perm memory footprint, and the PC is but the previous perm memory footprint. Other can be based on this analogy, OC is the pure amount of old.
[Root@localhost 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 the total amount of pure in old
PGCMN 8192.0 PGCMN shows the minimum amount of perm memory usage
PGCMX 65536.0 PGCMX Displays the maximum amount of memory used for Perm
PGC 12800.0 PGC is the current newly generated perm memory footprint
PC 12800.0 PC is but front perm memory footprint
YGC 164
FGC 6
Information for Jstat-gcnew pid:new objects
[Root@localhost 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
Information of Jstat-gcnewcapacity Pid:new object and its usage
[Root@localhost 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 Pid:old object's information.
[Root@localhost 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 the amount it occupies.
[Root@localhost 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 the amount it occupies.
[Root@localhost 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 about the current VM execution.
[Root@localhost 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>