1. What is JConsole
JConsole was introduced since Java 5. JConsole is a built-in Java performance analyzer that can be run from the command line or in a GUI shell. You can easily use JConsole (or, its higher-end "near relative" VisualVM) to monitor Java application performance and track code in Java.
2. How to start JConsole
1. If you start from the command line, just run jconsole on PATH.
2. If you start from the GUI shell, find the JDK installation path, open the bin folder, and double-click jconsole.
When the analysis tool pops up (depending on the running Java version and the number of Java programs running), a dialog box may appear asking to enter a process's URL to connect, or may list many different local Java processes (sometimes including the JConsole process itself) to connect. As shown in the figure:
If you want to analyze that program, double-click the process.
3. How to set the JAVA program to be connected and analyzed by JConsolse when it is run
1. Local program (relative to computers that enable JConsole), you can be connected to locally enabled without setting any parameters (Java SE 6 does not need to be set at the beginning, and you still need to set the runtime parameters before - Dcom.sun.management.jmxremote)
2. No authentication connection (the following settings indicate: the connection port is 8999, and it can be connected without authentication)
-Dcom.sun.management.jmxremote.port=8999 /-Dcom.sun.management.jmxremote.authenticate=false /-Dcom.sun.management.jmxremote.ssl=false
3. If security factors are taken into account, authentication is required and secure connection is required, it can also be done. Reference: http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdenv
4. How JConsole connects to remote machine JAVA program (example example)
1. Write a simple running JAVA program, run on a certain machine such as (192.168.0.181)
The code copy is as follows:
java -cp . -Dcom.sun.management.jmxremote.port=8999 -Dcom.sun.managent.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false JConsoleTest
2. Another machine is connected
You can use the command directly:
The code copy is as follows:
jconsole.exe 192.168.0.181:8999
You can also operate the connection in the already opened JConsole interface -> Create a new connection -> Select a remote process -> Enter the remote host IP and port number -> Click "Connection", as shown in the figure:
Then you will enter the analysis interface:
Performance Analysis
Let’s talk about how to analyze and how to use these six labels
• Overview: Displays overview information about the Java VM and monitored values.
• Memory: Display memory usage information
• Thread: Display thread usage information
• Class: Display class loading information
•*VM Summary:*Display java VM information
• MBeans: Show MBeans.
Then you will enter the analysis interface:
Overview
The overview is very simple and there is nothing to say. Let’s take a look at it yourself, but it is worth mentioning that right-clicking on the image can save data to the CSV file. You can use other tools to analyze this data in the future.
Memory
This is more valuable, see the status of heap memory, non-heap memory, memory pool overall memory allocation and usage, as well as the number and time of garbage collection by different GCs. You can manually check memory changes by GC.
It is very useful when analyzing JAVA memory problems for tuning. You need to learn the JVM memory model, and then you will find that each value here has meaning.
GC's algorithms and parameters have a significant impact on performance. Pay attention to the number of garbage collection times, time, as well as partial GC and full GC, adjust the different GCs you use and the parameters under each GC, and then observe in this view to obtain good performance.
Here is a diagram of the division of generations of generations of generative GC under Java HotSpot VM garbage collector:
For GC, please refer to: http://www.oracle.com/technetwork/java/gc-tuning-5-138395.html
Thread
The lower left corner shows all active threads (if there are too many threads, you can enter a string in the filter bar below to filter out the threads you want to observe). Clicking on a display will display the name, status, number of blocking and waiting times, and stack information of the thread.
The statistics chart shows the peak number of threads (red) and the currently active thread (blue).
In addition, there is a button below that "deadlock detected", which is sometimes useful.
kind
There is nothing to say.
VM Summary
There is nothing to say, let's take a look at the memory status, operating system...
MBean
There are some extra operations available here.
Plugin
jconsole -pluginpath C:/Java/jdk1.6.0_22/demo/management/JTop/JTop.jar
You can tell at a glance what it is.
It is recommended to use the upgraded version of JConsole, i.e. jvisualvm.
Regarding the use of jvisualvm, -> //www.VeVB.COM/article/77131.htm
References: