JMC (Java Mission Control) and JFR (Java Flight Recorder)
JMC has been included in the JDK since Java7, and it can be started by directly typing jmc
Before using it, you need to configure the Java process to support JMX connection, and add the configuration at startup
-Dcom.sun.management.jmxremote.port=7091
-Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.ssl=false
Unlock the commercial function and open the flight record configuration (choose one)
jcmd pid VM.unlock_commercial_features
-XX:+UnlockCommercialFeatures -XX:+FlightRecorder
jps : Java Virtual Machine Process Status Tool virtual machine process status tool
Syntax: jps [options] [hostid]
-q: only output PID
-m: output the parameters passed to the main method
-l: full package name or full pathname of the application JAR file
-v: View the specified parameter list when the virtual machine starts
Can list the running virtual machine processes, and display the virtual machine execution main class name and the local virtual machine unique ID of these processes
You can also query the process status of the remote virtual machine with the RMI service enabled through the RMI protocol. The parameter hostid is the host name registered in the RMI registry
jstat: virtual machine statistics monitoring tool
A command-line tool for monitoring various running status information of virtual machines
Can display runtime data such as class loading, memory, garbage collection, and even compilation in the virtual machine process
example
Query the garbage collection status of process 2764 every 250 milliseconds, a total of 20 queries
jstat -gc 2764 250 20
The query results show that the new generation Eden area (E) used by 2764 uses 6.2% of the space, the two Survivor areas (S0, S1) are empty, and the old generation (O) and the permanent generation use 41.42% and 47.20% of the space respectively , MinorGC (YGC) 16 times, time-consuming (YGCT) 0.105 seconds, Full GC (FGC) 3 times, time-consuming (FGCT) 0.472 seconds, total time-consuming of all GC (GCT) 0.577 seconds
jinfo: Java configuration information tool
View and adjust various parameters of the virtual machine in real time
jmap: Java memory mapping tool
Generate a heap dump snapshot, and you can also query the details of the finalize execution queue, Java heap, and method area