The JDK provides us with a range of JVM performance monitoring and troubleshooting tools, which are documented here based on learning progress. Easy to read later
1.JPS Virtual Machine Process Tool
Similar to the PS command in Linux systems for viewing virtual machine processes, the following features are commonly used
Jps-l Show virtual machine process ID and process main class
Jps-q shows only the process ID and does not display the main class name
JPS-M display the process ID and the arguments passed to main
Jps-v JVM Parameters when the output virtual machine process starts
2.jstat Virtual Machine Statistics monitoring tool
The tool is a command-line tool that monitors the various health status information for a virtual machine in the Format jstat [option Vmid [Interval[s|ms] [count]]
Intervals and count represent the query interval and number of times, and if these two parameters are omitted, then the query system is performed once. For example, if you need to query the garbage collection of process 2764 per 250ms for a total of 20 times, the command is as follows
JSATA-GC 2764 250 20
Let's take a look at the option that contains the content that can be queried
-class monitoring class Load unload quantity, total space and time consuming
-GC monitoring the status of the Java heap
-gccapacity is similar to GC in that it focuses on the maximum minimum control used by each region of the Java heap
-gcutil is similar to GC and focuses on using percentages
-gccause is similar to GC, which causes the last GC to work at an extra speed
-gcnew[capcity] New Generation GC status
-gcold[capcity] GC status in the old years
-compiler compiled methods and time-consuming
-printcompilation output has been JIT-compiled method
Sample Query Results
s0c s1c s0u s1u EC EU OC OU MC MU ccsu ygc ygct FGC fgct GCT
16896.0 14848.0 .....
C means the total size U represents to use the size
E represents the Cenozoic region Eden
s represents two Survivor0 and Survivor1
o denotes the old age
M represents the method area
CCS represents a compression class
YGC Generation Recovery times
YGCT New Generation Payback time
Number of FGC in the old age
FGCT old age recovery time
GCT Total Garbage collection time
3.jinfo real-time viewing and tuning of virtual machine parameters
You can use-flag Name=value to modify a subset of the run-time writable virtual machine parameter values
You can use the-flag name PID to view the specified parameter values. You can also jinfo pid to view all
4.jmap Java Memory Imaging tool
For generating heap storage snapshots, the main features are the following
-dump heap Storage Snapshot format is-dump:[live,]format=b,file=<filename> Live sub-parameter indicates whether to export only surviving objects
-finalizerinfo display object waiting for finalizer thread to execute Finalize method
-heap Show Heap Details
-histo displaying the object statistics for a heap
-permstat display permanent with memory status
-F Force generation of heap storage snapshots
5.jhat virtual machine heap dump snapshot analysis tool
Used in conjunction with JMAP to analyze jmap generated heap snapshots. Article authors do not recommend
6.jstack Java Stack Trace tool
The thread snapshot used to generate the current moment. The collection of method stacks that each thread in the current virtual machine is executing. Generating a thread snapshot Oh, yes. The main mapping is the reason for long pauses in locating threads such as deadlocks and dead loops
-F PID Force output thread stack
-L Display additional information about the lock in addition to the stack
-M can also display the local method's stack if the local method is called.
JDK Visualizer Jconsole and VISUALVM are no longer recorded because they are visually visualized
JVM performance monitoring and troubleshooting tools