Java Multi-Threading Monitoring and Analysis tool (VisualVM)

Source: Internet
Author: User
Tags jboss visualvm

Original link: http://blog.csdn.net/chendc201/article/details/22905511

In the Java multithreaded application run, in most cases we do not know what exactly happened, only the wrong log, we know that the original code is deadlock. Aside from the code-checking tool, let's talk about using VISUALVM monitoring to analyze the operation of our multithreaded operations.

Ad:51cto College: It quality courses online look!

In the Java multithreaded application run, in most cases we do not know what exactly happened, only the wrong log, we know that the original code is deadlock. Aside from the code-checking tool, let's talk about using VISUALVM monitoring to analyze the operation of our multithreaded operations. (Note: The version of JDK that practices this article requires 1.6.07 or more)

What is VISUALVM

VISUALVM is an integrated analysis tool for the JDK that has been part of the Sun's JDK since JDK 6 Update 7.

What VISUALVM can do: Monitor application performance and memory consumption, monitor application threads, thread dumps (thread dump) or heap dumps (heap dumps), track memory leaks, monitor the garbage collector, perform memory and CPU analysis, Save the snapshot for offline analysis of the application, and it also supports browsing and manipulation on Mbeans. Although the VISUALVM itself is running above JDK6, it can be monitored by the JDK1.4 version or later.

In the version above JDK1.6.07: to $java_home/bin, click the Jvisualvm.exe icon to start the VISUALVM, of course, you can also click here to get the latest official version, support: English, Chinese, Japanese.

VISUALVM feature Integration is more, we only discuss its object thread monitoring and analysis.

VISUALVM Monitoring Threads

When we run VISUALVM, we can see VISUALVM and Eclipse running programs locally in the application. Then we start one of the threads in Eclipse: com.longtask.thread.TestVisualVm, you can see that there is one more display of the thread in the menu. Click on the Thread menu on the right to see the tracking of the thread running.

Click on thread dump to generate the Tdump file that runs the thread, and with the relevant information provided by thread dump, we can see where the thread is blocked and the other state of the thread.

Save the log as a file, go to Thread Dump Analyzer's homepage, click the icon to download the TDA, and then use the TDA to open the thread dump file just VISUALVM saved to view the relevant analysis results.

We can also use VISUALVM to monitor the operation of remote Java threads.

Remote monitoring: Start RMI Service

1: Create a new Jstatd.all.policy file and add the following to ensure that the JSTATD service does not report an exception when it starts:

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

2:netstat-ano | Grep-i 1099 See if 1099 ports are occupied and if they are occupied, you need to select a different port to start the JSTATD service

3: If the port is occupied, start the JSTATD service in the following ways:

    1. Rmiregistry 2020 & jstatd-j-djava.security.policy=jstatd.all.policy-p 2020

For more JSTATD documentation please refer to Sun's official documentation here

Remote Monitoring Jboos Service

1: Modify the JMX configuration file under the JDK:

Switch to the directory where $java_home is located/jre/lib/management,

I: Adjust jmxremote.access, jmxremote.password.template permissions to read and write:

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

Ii:vi Jmxremote.password Remove

# Monitorrole QED

# Controlrole

The # number

2: Add the following information in the JBoss startup file:

    1. java_opts= "-dcom.sun.management.jmxremote.port=2899 \
    2. -dcom.sun.management.jmxremote.ssl=false \
    3. -dcom.sun.management.jmxremote.authenticate=false \
    4. -djava.rmi.server.hostname=10.212. 20.9 additional Configuration "

3: Check the boot situation:

netstat-a | Grep-i 2899 Viewing port occupancy

If Port 2899 is occupied by another program, adjust the port-dcom.sun.management.jmxremote.port=**** in the JBoss configuration file

Then add the remote connection in the VISUALVM, choose the JMX mode, you can monitor the operation of JBoss.

(RPM) Java Multi-Threading Monitoring Analysis tool (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.