In the Java Bin directory, the JDK provides a lot of tools to use, and below to learn some of the tools for monitoring and troubleshooting.
Name
Role
JPS JVM Process Status tool to display all the HotSpot virtual machine processes within a specified system
Jstat JVM Statistics Monitoring tool for collecting operational data for all aspects of the HotSpot virtual machine
Jinfo displaying virtual machine configuration information
Jmap Memory Snapshot dump file for production virtual machines
Jhat Analysis dump File
Jstack displaying a thread snapshot of a virtual machine
JPS Virtual machine Process Health tool
JPS command format:
JPS [Options] [HostID]
1
2
3
4
5
6
7
>jps-l
25330 Sun.tools.jps.Jps
25296
>jps-lv
25356 sun.tools.jps.jps-dapplication.home=/library/java/javavirtualmachines/jdk1.7.0_71.jdk/contents/home-xms8m
25296-dosgi.requiredjavaversion=1.6-xstartonfirstthread-dorg.<span class= "Wp_keywordlink" ><a href= "http ://res.importnew.com/eclipse "title=" Eclipse importnew Home "target=" _blank ">ECLIPSE</A></SPAN>. swt.internal.carbon.smallfonts-xx:maxpermsize=256m-xms40m-xmx512m-xdock:icon=. /resources/eclipse.icns-xstartonfirstthread-dorg.eclipse.swt.internal.carbon.smallfonts
JPS can view the status of the original virtual machine process that opened the RMI service through the RMI protocol, HostID is the host registered in the RMI registry.
JPS has the following main options:
Options
Role
-Q only outputs Lvmid, omitting the name of the main class
-m outputs the parameters passed to the main method when the virtual machine is started
-L Output Class full name
-V Output JVM parameters when the virtual machine process starts
Jstat Virtual Machine Statistics monitoring tool
Jstat can display class loading, memory, garbage collection, JIT compilation, and other running data in a local or remote virtual machine process.
Jstat command format:
jstat [option Vmid [interval] [count]]
For example:
1
2
3
4
5
6
7
>jstat-gcutil 25296 1000 5
S0 S1 E O P ygc ygct FGC fgct GCT
0.00 99.54 90.43 93.70 95.23 55 1.156 5 1.990 3.146
0.00 99.54 90.43 93.70 95.23 55 1.156 5 1.990 3.146
0.00 99.54 90.43 93.70 95.23 55 1.156 5 1.990 3.146
0.00 99.54 90.43 93.70 95.23 55 1.156 5 1.990 3.146
0.00 99.54 90.43 93.70 95.23 55 1.156 5 1.990 3.146
Queries the virtual machine state of the 25296 process, and displays 5 times every 1000 milliseconds.
Look at the meaning of the main option:
Options
Role
-class Monitor class load, unload quantity, total see, and time of class load consumption
-GC monitor Java heap status, including Eden Zone, two survivor zone, old generation, permanent generation, capacity, used space, GC time totals, etc.
The-gccapacity content is basically the same as the-GC, and the output focuses on the maximum and minimum space used by each area of the Java heap
-gcutil content is basically the same as-GC, focusing on the percentage of total space used
-gccause content is the same as-gcutil, and multiple outputs cause the last GC to produce
-gcnew Monitoring of Cenozoic status
-gcnewcapacity is the same as-gcnew, focusing on the maximum and minimum space used
-compiler output JIT compiler compiled methods, time-consuming and other information
The following is an explanation of what-gcutil produces:
S0, S1 respectively represent the Survivor0 and survivor1,e represent the Eden area, O represents the old age area, P represents the permanent generation. YGC represents the number of times the young GC, YGCT represents time, as explained later.
Jinfo Viewing the Java Configuration Information tool
This command is relatively straightforward and looks directly at its own description:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
Usage:
jinfo [option] <pid>
(to connect to running process)
jinfo [option] <executable <core>
(to connect to a core file)
jinfo [option] [[Email protected]]<remote server IP or hostname>
(To connect to Remote debug server)
Where <option> is one of:
-flag <name> to print the value of the named VM flag
-flag [+|-]<name> to enable or disable the named VM flag
-flag <name>=<value> to set the named VM flag to the given value
-flags to print VM flags
-sysprops to print Java System Properties
<no option> to print both of the above
-H | -help to print this help message
Jmap production of Java memory dump
In addition to generating dump files, Jmap can query the details of the Finalize execution queue, Java heap, and permanent generation, such as the space usage and which collector is currently in use.
Specific Jamp How to operate the Department of the introduction, see the instructions provided below, relatively simple:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21st
22
23
24
25
26
27
28
Usage:
jmap [option] <pid>
(to connect to running process)
jmap [option] <executable <core>
(to connect to a core file)
jmap [option] [[Email protected]]<remote server IP or hostname>
(To connect to Remote debug server)
Where <option> is one of:
<none> to print same info as Solaris Pmap
-heap to print Java heap summary
-histo[:live] To print histogram of Java object heap; If the "Live"
Suboption is specified, only count live objects
-permstat to print permanent generation statistics
-finalizerinfo to print information on objects awaiting finalization
-dump:<dump-options> to dump Java heap in hprof binary format
Dump-options:
Live dump only live objects; If not specified,
All objects in the heap is dumped.
Format=b binary format
File=<file> dump Heap to <file>
Example:jmap-dump:live,format=b,file=heap.bin <pid>
-F Force. Use with-dump:<dump-options> <pid> Or-histo
To force a heap dump or histogram if <pid> does not
Respond. The "Live" suboption is not supported
In the This mode.
-H | -help to print this help message
-j<flag> to pass <flag> directly to the runtime system
Jhat Virtual Machine heap Snapshot analysis tool
We can use Jhat to analyze the dump file generated by Jmap
1
2
3
4
5
6
7
8
9
10
11
12
13
>jhat Tmp.dump
Reading from Tmp.dump ...
Dump file created Sat 17:10:52 CST 2015
Snapshot Read, resolving ...
Resolving 0 objects ...
Warning:hprof file does not include java.lang.class!
Warning:hprof file does not include java.lang.string!
Warning:hprof file does not include java.lang.classloader!
Chasing references, expect 0 dots
Eliminating duplicate references
Snapshot resolved.
Started HTTP server on port 7000
Server is ready.
By default, 7000 ports are opened for Web Access. Typically, this command is not used for analysis, and professional tools are used to analyze dump files, such as Eclipse Memory Analyzer.
Jstack parsing the Java stack
The jstack is used to generate thread snapshots at the current moment.
Use the following methods:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Usage:
Jstack [-l] <pid>
(to connect to running process)
Jstack-f [-M] [-l] <pid>
(to connect to a hung process)
Jstack [-M] [-l] <executable> <core>
(to connect to a core file)
Jstack [-M] [-l] [[email protected]]<remote server IP or hostname>
(to connect to a remote debug server)
Options:
-F to force a thread dump. Use if Jstack <pid> does not respond (process is hung)
-M to print both Java and native frames (mixed mode)
-L Long listing. Prints additional information about locks
-H or-help To print this help message
Resources
1. In-depth understanding of JAVA virtual machines
In the Java Bin directory, the JDK provides a lot of tools to use, and below to learn some of the tools for monitoring and troubleshooting.