JVM Performance Tuning monitoring Tools JPS, Jstack, Jstat, Jmap, Jinfo use detailed

Source: Internet
Author: User
Tags dbx jconsole

is whatJPs

View all JVM processes, including process IDs, process-initiated paths, and so on.

I use it myself . PS, i.e.:ps-ef | grep java

Jstack

observe The operation of all current threads in the JVM and the current state of the thread.

the system crashed? If a Java program crashes generating a core file,the Jstack tool can be used to obtain the Java stack and native for the core file Stack of information, so you can easily know how the Java program crashes and where the problem occurs in the program.

The system hung live? the Jstack tool can also be attached to a running Java program and see the Java stack and native of the Java Program that was running at that time Stack information , Jstack is very useful if the Java program that is running now renders the Hung state .

Jstat

Jstat uses the JVM 's built-in instructions to monitor the resources and performance of Java applications in real time, including ClassLoader of Processes,compiler, GC situation;

In particular, a very strong tool for monitoring memory that can be used to monitor The size of various heap and non-heap in VM memory, and the amount of memory used, as well as the number of loaded classes.

Jmap

Monitor The consumption of the JVM's physical memory in the process running, the process in memory, the circumstances of all objects, such as which objects were produced, the number of objects;

the system crashed? Jmap can get the exact match of memory from the core file or process, including Heap size, Perm size, etc.

Jinfo

Observe the process run environment parameters, including Java System Properties and JVM command-line arguments

the system crashed? Jinfo can know the configuration information of the crashed Java application from inside the core file .

Notes

If you can skillfully use these commands, especially under Linux, you can completely replace the Jprofile and other monitoring tools.

the advantage of the command is that it is fast and assists other commands, such as grep gawk sed , to assemble a variety of tools to suit your needs.

How to use

==================== The following is more commonly used ====================

Jstat

The specific parameters are as follows:

-class: Statistics class loader behavior Information-compile: Statistical compilation Behavior Information-GC: Statistics of JDK GC when heap information-gccapacity: Statistics of different generations (including the freshman district, the old age area, Permanent area) The corresponding heap capacity situation-gccause: Statistics GC, (same-gcutil) and the event that caused the GC-gcnew: When statistical GC, the Cenozoic situation-gcnewcapacity: When statistical GC, the Cenozoic heap capacity- Gcold: Statistics GC, the situation of the elderly area-gcoldcapacity: Statistics GC, old age area heap capacity-gcpermcapacity: Statistical GC, permanent area heap capacity-gcutil: Statistics GC, heap situation

$ jstat-class 17970 (monitored every 1 seconds for a total of ten times )
Loaded Bytes Unloaded Bytes time
7837 8534.0 1069) 1005.7 27.87

Loaded:number of Classes Loaded.

Bytes:number of Kbytes loaded.

Unloaded:number of Classes Unloaded.

Bytes:number of Kbytes unloaded.

Time:time spent performing class load and unload operations.

$ JSTAT-GC 17970 (monitor once every 2 seconds, a total of three times )

$ jstat-gcutil 17970 ( Explicit by percentage )
s0c s1c s0u s1u EC EU OC OU PC PU YGC YGCT FGC FGCT GCT
15936.0 15936.0 9030.8 0.0 127872.0 61813.5 901120.0 544712.5 65536.0 35227.8 42078 2796.028 417 498.596 329 4.624

s0c:Current survivor Space 0 capacity (KB).

S1C:Current survivor Space 1 capacity (KB).

s0u:Current survivor Space 0 utilization (KB).

S1U:Current survivor Space 1 utilization (KB).

EC:current Eden Space Capacity (KB).

EU:Eden Space Utilization (KB).

OC:Current old space Capacity (KB).

OU:old space Utilization (KB).

PC:Current permanent space capacity (KB).

PU:Permanent Space Utilization (KB).

YGC:number of young generation GC Events.

YGCT:Young Generation garbage collection time.

FGC:number of full GC events.

FGCT:full garbage collection time.

GCT: Totalgarbage collection time.

$ Jstat-compiler 17970 (displays information such as the number of VMS in real-time compilation)
Compiled Failed Invalid Time Failedtype Failedmethod
3780 1 0 120.26 2 com/xxx/xxx Run

Jstat–gccapacity: You can displaythe usage and occupancy of three-generation (Young,old,perm) objects in VM memory, such as:pgcmn shows the minimum perm The amount of memory used, PGCMX shows the maximum memory usageof Perm, the PGC is the current newly generated perm memory footprint,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.

[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 a pure occupancy 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

[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

Jstat-gcnewcapacity information of Pid:new objects and their consumption

[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 information for the Pid:old object.

[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 its consumption.

[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 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 millisecond, 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>

Jmap

Jmap-dump:format=b,file=dump.bin PID

Jmap can obtain specific memory matches from the core file or process, including the Heap size, Perm size, and so on, currently only available in Solaris and Linux JDK version.

Observe the physical memory usage of the JVM in operation

print out a Java process (using PID) in memory, all the ' objects ' in the case (e.g., which objects are produced, and their number).

a tool that can output all in-memory objects, and can even the heap in the VM, with binary output as text. Use the method jmap-histo pid. If you use the SHELL jmap-histo pid>a.log can save it to the text, after a period of time, using the text Comparison tool, you can compare what the GC recycled objects. jmap-dump:format=b,file=string 3024 can output the memory heap of the 3024 process to a String file.

[Email protected] bin]# Jmap-histo 25917

Attaching to process ID 26221, please wait ...

Debugger attached successfully.

Client compiler detected.

JVM version is 1.5.0_08-b03

Iterating over heap. This is a while ...

Unknown OOP at 0xaa6e42d0

Oop ' s Klass is null

Object Histogram:

Size Count Class Description

-------------------------------------------------------

3722768 30467 * Constmethodklass

1976480 25334 char[]

1907880 46994 * Symbolklass

1762088 2947 byte[]

1709536 30467 * Methodklass

1487816 2600 * Constantpoolklass

1009576 2600 * Instanceklassklass

904880 2199 * Constantpoolcacheklass

741432 30893 java.lang.String

653576 4785 int[]

351760 4397 Java.lang.reflect.Method

277824 2894 Java.lang.Class

248704 3401 short[]

200888 4411 java.lang.object[]

193656 4045 java.lang.object[]

179744 5617 Java.util.treemap$entry

175688 1800 java.util.hashmap$entry[]

165288 6887 Java.util.hashmap$entry

104736 3273 java.lang.ref.SoftReference

104136 4339 Java.lang.ref.WeakReference

96096 3521 java.lang.string[]

86160 3590 Java.util.hashtable$entry

85584 3566 java.util.ArrayList

83472 1206 java.util.hashtable$entry[]

82944 1728 Java.beans.MethodDescriptor

80560 265 * Objarrayklassklass

69120 1728 Java.util.HashMap

52464 3055 java.lang.class[]

43040 1076 Java.util.Hashtable

42496 664 Org.apache.commons.modeler.AttributeInfo

37880 947 Java.util.TreeMap

33896 557 javax.management.modelmbean.modelmbeanattributeinfo[]

33152 518 Java.beans.PropertyDescriptor

616 Org.springframework.aop.framework.ProxyFactory

608 Java.util.PropertyPermission

608 Org.springframework.beans.MutablePropertyValues

608 Org.springframework.beans.factory.support.MethodOverrides

608 2 * Arrayklassklass

608 Org.springframework.beans.factory.config.ConstructorArgumentValues

608 4 Org.apache.xerces.impl.XMLDTDScannerImpl

576 Java.util.Stack

576 java.util.regex.pattern$category

576 org.apache.naming.NamingEntry

560 7 java.net.url[]

552 Sun.management.mappedmxbeantype$basicmxbeantype

552 1 java.util.locale[]

552 java.io.objectstreamfield[]

544 Java.util.collections$synchronizedmap

176 Java.util.regex.pattern$ctype

8 1 sun.reflect.GeneratedMethodAccessor49

8 1 Sun.reflect.GeneratedMethodAccessor6

8 1 Sun.reflect.GeneratedConstructorAccessor10

Heap traversal took 12.003 seconds.

Jinfo

you can output and modify the opts of the Java process at runtime. The utility is simple enough to output and modify the runtime parameters of the Java process. Usage is jinfo-opt pid such as: View 2788 MaxPerm size can be used jinfo-flag maxpermsize 2788 .

Extracurricular supplementJstatd

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

start The JVM monitoring service. It is an RMI-based application that provides information about native JVM applications to remote machines . The default port is 1099.
Example:jstatd-j-djava.security.policy=my.policy
the My.policy file needs to be built itself, as in the following:
Grant codebase "File: $JAVA _home/lib/tools.jar" {
Permission java.security.AllPermission;
};

Jdb

JDB is used to debug core files and running Java processes in real-time, with rich commands to help you debug, its functionality and the features of Sun Studio DBX is very similar, but Jdb is specifically intended for Java applications.

used to debug core files and running Java processes in real time, with rich commands to help you debug, its functionality and the DBX in Sun Studio Very similar, but Jdb is specifically intended for Java applications.

Jconsole

Jconsole is a real-time graphical monitoring tool based on (JMX) that leverages the JMX instructions built into the JVM to provide real-time performance and resource monitoring, including Java memory usage of the program, Heap size, the state of the thread, the allocation state of the class, the use of space, and so on.

Equivalent to jstat .

Jconsole: A Java GUI Monitoring tool that can display a variety of data in a tabular format. Remote server VMS can be monitored through remote connections .

a GUI program written in Java, used to monitor VMS,and to monitor remote VMS, is very easy to use and very powerful. Command line to play jconsole, select the process is OK.

JVM Performance Tuning monitoring Tools JPS, Jstack, Jstat, Jmap, Jinfo use detailed

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.