JVisualVM is a performance analysis tool provided by Sun. How can such a powerful backing not be powerful? It comes with versions after Jdk6.0. Configure the environment variables and enter "JVisualVm" during operation or directly search the Bin directory of Jdk's installation directory to run. If you are using Jdk1.5 or previous version, you have to install it separately.
I think another powerful thing is that it does not need to be started with a proxy (that is, if you want to monitor a program, you need to use test software to run the program to facilitate its monitoring of similar test tools such as YourKit). It is very convenient. As long as it is run in the Jdk environment, you can see and monitor the running status after opening this test tool. Of course, the premise is to run in the same Jdk environment.
Address: https://visualvm.dev.java.net/
connect
1. The local machine's program can be listened directly to
2. The remote machine program needs to add JVM parameters
-Dcom.sun.management.jmxremote= true
-Dcom.sun.management.jmxremote.port= 9090
-Dcom.sun.management.jmxremote.ssl= false
-Dcom.sun.management.jmxremote.authenticate= false
Note: Also checked
hostname i
Check whether it is a local IP. If 127.0.0.1 or the IP is one of multiple IPs, the other IPs are invalid and the connection will not be possible.
Here is an analysis case, using jvisualvm to analyze the problem of tomcat:
http://blog.tty.nl/2010/09/03/using-visualvm-to-fix-live-tomcat-and-jvm-problems
Plugin installation
tools->plugin->Available Plugin will have plugins worth installing, such as: VisualGC JConsole
Plugin list: https://visualvm.dev.java.net/plugins.html
Note: The port configuration provided above is a bit troublesome, so why not do it directly:
To use VisualGC, you must start the jstatd agent on the remote machine, otherwise the "not supported for this jvm" error will be displayed. There will be a permission problem when starting jstatd, which needs to be modified as follows:
nano /opt/sun-jdk- 1.6. 0.26 /jre/lib/security/java.policy
The code copy is as follows:
nano /opt/sun-jdk-1.6.0.26/jre/lib/security/java.policy
Add the following lines
The code copy is as follows:
grant codebase "file:${java.home}/../lib/tools.jar" {
permission java.security.AllPermission;
};
Then start jstatd and don't close
like:
Threads
Check the running status of the thread, run, stop, sleep, wait, and analyze the logic of running in combination with actual program.
To find the suspicious person, you can find out which thread is at the moment.
See this example: http://blog.tty.nl/2010/09/03/using-visualvm-to-fix-live-tomcat-and-jvm-problems
For how to use and analyze the program, you can refer to this example: http://www.baptiste-wicht.com/2010/07/profile-applications-java-visualvm