Jstat is a JDK A lightweight gadget that comes with it. Full name "Java Virtual machine Statistics monitoring Tool".
Jstat is located Java of the bin directory, the main use of JVM built-in instructions to Java The application's resources and performance are monitored in real-time by the command line, including the Heap Size and monitoring of garbage collection status.
Jstat can be used to monitor VMS the size of various heap and non-heap in memory and its memory usage.
1 , Jstat command format
Jstat [Optionsvmid [Interval[s|ms] [count]]
2 , common parameters
1. Options is the type of virtual machine that the user wants to query
Jstat-classpid: Displays information such as the number of loaded classes, and the amount of space 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.
2.vmid virtual machine identifier in the format: [protocol :][//]lvmid [@hostname [:Port ]/ ServerName ]
3.interval is the display interval
4.count is the number of displays
3 , source code
Package com.jdktools;
Import java.util.ArrayList;
Import Java.util.Random;
/**
* Simple application with a large number of loops and objects created for testing the JDK's own jstat use
* Parameter:-xms30m-xmx60m
*
* @author Fan Fangming
*/
Public Classeasyjstat {
Public Byte[]placeholder = new byte[1 * 1024]; Placeholder
public static void Main (string[] args) throws Exception {
while (true) {
Randomrandom = new Random ();
int loops = Random.nextint (10000);
Easyjstatjstat = new Easyjstat ();
System. out. println ("... Building object: "+ Loops +" (one) ");
Jstat.getloop (loops);//multiple loops, resulting in a large number of objects
Thread. Sleep (10);
}
}
public voidgetloop (int size) {
Arraylist<easyjstat>list = newarraylist<easyjstat> ();
for (int i = 0; i < size; i++) {
Easyjstatjstat = new Easyjstat ();
List.add (Jstat);
}
}
}
4 , operating parameters
* parameters:-xms30m-xmx60m , this parameter is used to start the JVM virtual machine
5 , running results
C:\Program files\java\jdk1.6.0_25\bin>jps-v
7588 jps-dapplication.home=c:\programfiles\java\jdk1.6.0_25-xms8m
2856-xms256m-xmx768m-xx:maxpermsize=256m-xx:reservedcodecachesize=64m-dosgi.nls.warnings=ignore
7672 EASYJSTAT-XMS30M-XMX60M-DFILE.ENCODING=GBK
C:\Program FILES\JAVA\JDK1.6.0_25\BIN>JSTAT-GC 7672250 6
s0c s1c s0u s1u EC EU OC OU
192.0 192.0 0.0 191.2 2048.0 0.0 28416.0 25772.5
192.0 192.0 191.2 0.0 2048.0 0.0 28416.0 19050.2
192.0 192.0 0.0 191.2 2048.0 0.0 28416.0 22142.5
192.0 192.0 0.0 191.9 2048.0 0.0 28416.0 26059.4
192.0 192.0 0.0 0.0 2048.0 0.0 28416.0 6885.8
192.0 192.0 0.0 191.7 2048.0 0.0 28416.0 6967.4
...
where s0c represents the current S0 capacity (KB), s1c represents the current S1 capacity (KB), and the EC represents the current Eden Capacity (KB) and so on.
we know that the data of the two survivor areas is exchanged, and it is evident here that the space usage of s0u and s1u is alternating.
Reference:
Http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html
http://blog.csdn.net/gtuu0123/article/details/6125919
The jstat of the JDK with its own tools