With JVM monitoring, we can understand the internal process of GC, know when new generation objects are moved to old age, when GC occurs, and how long GC lasts.
In order to tune the JVM, it is necessary to know the current state of the JVM. JVM monitoring is an essential step. Here are three common ways to monitor the JVM.
jstat
One of the most primitive and efficient ways to do this is to do no additional configuration for your Java application. The tools are available by default when you install the JDK, and a single Jstat can do most of what you need to know about JVM health.
Jstat is usually installed with a Java program, which we can take a look at.
2 use
Jstat -class -t 79065 1000 5 jstat -class -t 79065 1000 5 jstat -class -t 79065 1000 5
jstat -<option> [-t] [-h<lines>] <vmid> [<interval> [<count>]]
# Jstat can monitor the followingJstat-options-class Collects statistics about classloads in the JVM. - Compiler Collects statistics about the JIT compiler. - GC Collects statistics about gc heap memory - GcMetacapacity - gcNew Collects information about the new generation. - gcnewCapacity -gcold Collects information about the old generation. - gcoldCapacity -gcutil Displays statistics about the GC -printcompilation displays compilation method statistics for the JVMCopy the code
Explanation:
Capacity of VIABILITY zone 0 in S0C (KB) Capacity of viability zone 1 in S1C (KB) Space used by viability zone 0 in S0U (KB). Space used by viability zone 1 in S1U (KB) OU Used capacity of the old age (KB). PC Current capacity of the permanent band (KB). PU Used capacity of the permanent band (KB). YGC Number of times that Young GC occurs GC collection time GCT Total GC time.
See above is not found, simple and direct effective.
Jconsole or jvisualvm
Jvisualvm may need to be downloaded online, but both tools access the JVM through JMX for statistics and specify the JMX content when starting the JVM.
Method 1: Specify a password to enhance security
java -Dcom.sun.management.jmxremote.port=5000 -Dcom.sun.management.jmxremote.password.file=/Users/aihe/Documents/jmxremote.password -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false- Dcom. Sun. Management. Jmxremote. Access the file = / Users/aihe/Documents/jmxremote access - jar target/jmxdemo - 0.0.1 - the SNAPSHOT. The jarCopy the code
arthas
Ali open source a good JVM monitoring tool, a bit like the JDK in its own command line tools to do a collection.
1 installation
# Installation method 1
curl -L https://alibaba.github.io/arthas/install.sh | sh
# Installation method 2
java -jar arthas-boot.jar --repo-mirror aliyun --use-http
Copy the code
2 use
java -jar arthas-boot.jar
Copy the code
Reference address: alibaba. Making. IO/arthas/inst…
Pay attention to
Remember to shutdown when you’re done. If you don’t shutdown, you might have some problems, such as monitoring the last JVM process, so use shutdown first.
The last
This introduction introduces my common monitoring JVM tools, if there is a better tool, please recommend to me