How to use JVISUALVM for performance analysis in Java development _java

Source: Internet
Author: User
Tags visualvm

JVISUALVM is the performance analysis tool provided by sun, how can such a strong backing not be strong? The Jdk6.0 version is self-contained, configured with an environment variable and then run by entering "JVISUALVM" in run or directly to the bin directory of the JDK's installation directory. If you are using a Jdk1.5 or a previous version of a friend, you have to install it separately.

I think there is a strong point is that there is no need to use a proxy startup (that is, if you want to monitor a program needs to use test software to run the program to facilitate its monitoring, such as Yourkit this type of test tools) to run, very convenient, as long as the JDK environment to run, When you open this test tool, you will be able to see and monitor the level of running status, assuming that you are running in the same JDK environment.


Address: https://visualvm.dev.java.net/

Connection

1, the local machine procedures can be directly monitoring the hearing

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: Another need to check


Hostname–i

See whether the resolution is local IP, if 127.0.0.1 or IP is one of multiple IP, then the other IP is invalid, will not connect.

Here's a case study that uses JVISUALVM to analyze Tomcat's problem:

Http://blog.tty.nl/2010/09/03/using-visualvm-to-fix-live-tomcat-and-jvm-problems

Plug-in installation

Tools->plugin->available plugin will have plug-ins that are worth installing, such as: VISUALGC Jconsole

Plugin list: https://visualvm.dev.java.net/plugins.html

Note: The port configuration provided above is a bit of a hassle, so do it directly:

To use VISUALGC you must start the JSTATD agent on the remote machine, otherwise the not supported to this JVM error is displayed
When you start jstatd, you have a permission issue that requires the following modifications:
nano/opt/sun-jdk-1.6. 0.26/jre/lib/security/java.policy

Copy Code code as follows:

Nano/opt/sun-jdk-1.6.0.26/jre/lib/security/java.policy

Add the following line

Copy Code code as follows:

Grant codebase "file:${java.home}/." /lib/tools.jar "{
Permission java.security.AllPermission;
};

Then start jstatd and do not close

Such as:


Threads


Look at the running of threads, run, stop, sleep, wait, logical analysis based on these actual programs.

If you find a suspect, you can thread Dump to find out exactly which thread is at work.

Refer to this example: Http://blog.tty.nl/2010/09/03/using-visualvm-to-fix-live-tomcat-and-jvm-problems

Profile

For information on how to use and how to analyze a program, see this example: HTTP://WWW.BAPTISTE-WICHT.COM/2010/07/PROFILE-APPLICATIONS-JAVA-VISUALVM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.