JDK's built-in tool jstat, jdk's built-in jstat

Source: Internet
Author: User

JDK's built-in tool jstat, jdk's built-in jstat

Jstat is a lightweight tool that comes with JDK. The full name is "Java Virtual Machine statistics monitoring tool ".

Jstat is located in the bin directory of java. It monitors the resources and performance of Java applications in real time using built-in JVM commands, this module monitors Heap size and garbage collection.

Jstat can be used to monitor the size and memory usage of various heaps and non-heaps in the VM memory.

1. Jstat Command Format

Jstat [optionsvmid [interval [s | MS] [count]

2. Common Parameters

1. options is the type of virtual machine you want to query

Jstat-classpid: displays the number of loaded classes and the occupied space.

Jstat-compiler pid: displays information such as the number of real-time VM compilations.

Jstat-gc pid: displays gc information, the number of gc times, and the time. The last five items are the young gc count, young gc time, full gc count, full gc time, and total gc time.

Jstat-gccapacity: displays the usage and usage of three generations (young, old, and perm) objects in the VM memory. For example, pgcen displays the minimum perm memory usage, PGCMX displays the maximum memory usage of perm. PGC is the memory usage of the newly generated perm, while PC is the memory usage of the previous perm. For others, the OC usage is pure in old.

Jstat-gcnew pid: information of the new object.

Jstat-gcnewcapacity pid: information about the new object and its usage.

Jstat-gcold pid: information of the old object.

Jstat-gcoldcapacity pid: information about the old object and its usage.

Jstat-gcpermcapacity pid: information of the perm object and its usage.

Jstat-util pid: Statistics of gc information.

Jstat-printcompilation pid: information about 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 indicates the number of display times.

 

3. Source Code

Package com. jdkTools;

 

Import java. util. ArrayList;

Import java. util. Random;

 

/**

* Simple applications have a large number of loops and objects to be created for testing the built-in JDKJstatUse

* 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 + "(items )");

Jstat. getLoop (loops); // multiple loops generate 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. Running Parameters

* Parameter:-Xms30m-Xmx60m. this parameter is used to start a jvm vm.

5. Running result

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 = 256 m-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

192.0 192.0 191.2 0.0 2048.0 0.0 28416.0

192.0 192.0 0.0 191.2 2048.0 0.0 28416.0

192.0 192.0 0.0 191.9 2048.0 0.0 28416.0

192.0 192.0 0.0 0.0 2048.0 0.0 28416.0

192.0 192.0 0.0 191.7 2048.0 0.0 28416.0

...

S0C indicates the current S0 capacity (KB), S1C indicates the current S1 capacity (KB), and EC indicates the current eden capacity (KB), and so on.

We know that the data in the two vor zones is marked for exchange. here we can see that the space usage of S0U and S1U is alternating.

Refer:

Http://docs.oracle.com/javase/1.5.0/docs/tooldocs/share/jstat.html

Http://blog.csdn.net/gtuu0123/article/details/6125919

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.