How to use Jconsole to observe and analyze the operation of Java program, and to perform debugging and tuning

Source: Internet
Author: User
Tags jconsole java se

First, what is Jconsole?

JConsole has been introduced from Java 5. JConsole is a built-in Java Performance Analyzer that can be run from the command line or in the GUI shell. You can easily monitor Java application performance and track code in Java using JConsole (or its more advanced "close relatives" VisualVM).

Second, how to start jconsole
    1. If you are starting from the command line, make the JDK on PATH and run Jconsole.
    2. If booting from the GUI shell, locate the JDK installation path, open the Bin folder, and double-click jconsole .

When the analysis tool pops up (depending on the version of Java that is running and the number of Java programs that are running), a dialog box may be required to enter the URL of a process to connect, or it may list many different native Java processes (sometimes including the JConsole process itself) to connect. :

To analyze the program, double-click the process.

Third, how to set the Java program Runtime can be jconsolse connection analysis
    1. Local program (relative to the computer on which Jconsole is turned on), Jconsole connection can be opened locally without setting any parameters (Java SE 6 does not need to be set at the beginning, before you need to set the runtime parameters-dcom.sun.management.jmxremote)
    2. No authentication connection (the following setting means: The port of the connection is 8999, can be connected without authentication) Java code
      1. -dcom.sun.management.jmxremote.port=8999 \
      2. -dcom.sun.management.jmxremote.authenticate=false \
      3. -dcom.sun.management.jmxremote.ssl=false
      -dcom.sun.management.jmxremote.port=8999-dcom.sun.management.jmxremote.authenticate=false- Dcom.sun.management.jmxremote.ssl=false
    3. If you consider the safety factor, need authentication, need secure connection, also can be done. Reference: Http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html#gdenv
Iv. Jconsole How to connect a remote machine's Java program (example)

1, write a simple running Java program, running on a machine such as (192.168.0.181)

Java code
    1. JAVA-CP. -dcom.sun.management.jmxremote.port=8999-dcom.sun.managent.jmxremote.authenticate=false- Dcom.sun.management.jmxremote.ssl=false jconsoletest
JAVA-CP. -dcom.sun.management.jmxremote.port=8999-dcom.sun.managent.jmxremote.authenticate=false- Dcom.sun.management.jmxremote.ssl=false Jconsoletest

2, another machine to connect

You can use the command directly:

Java code
    1. Jconsole.exe 192.168. 0.181:8999
Jconsole.exe 192.168.0.181:8999

You can also click "Connect" on the remote host IP and port number, select Remote process-----new connection, which already opens the Jconsole interface operation connection

Then you will enter the analysis interface:

Performance analysis

Below is how to analyze how to use these six tags

    • Overview: Displays overview information about the Java VM and monitored values.
    • Memory: Display memory usage information
    • threads: displaying thread usage information
    • class: Display class loading information
    • *VM Summary: * Display Java VM information
    • MBeans: displays MBeans.
Overview

Overview very simple nothing to say, see for yourself, but it is worth mentioning that right-click on the map to save the data to a CSV file, you can use other tools to analyze the data later.

Memory

This is valuable in terms of heap memory, non-heap memory, the state of the memory pool, the allocation and usage of overall memory, and the number and time of garbage collection by different GC. You can manually perform GC view memory changes.

It is useful to analyze Java memory issues for tuning, you learn the JVM memory model, and then you find that each value here has meaning.

GC Algorithms and parameters have a significant impact on performance, note the number of garbage collections, the time, and the partial GC and full GC, adjust the different GC and GC parameters you use, and then look at it under this view to get good performance.

Here is a map of the generations of the generational GC under Java HotSpot VM garbage collector:

For GC, 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 thread you want to see). Clicking on a display displays the name, status, number of blocks and waits of the thread, and the stack's information.

The chart shows the peak (red) of the number of threads and the currently active thread (blue).

In addition, there is a button "deadlock detected", sometimes useful.

Class

There's nothing to say.

VM Summary

There is nothing to say, look at it, memory status, operating system ...

Mbean

There are some extra things to do here.

Plugin Java code
    1. Jconsole-pluginpath C:\Java\jdk1. 6.0_22\demo\management\jtop\jtop.jar
Jconsole-pluginpath C:\Java\jdk1.6.0_22\demo\management\JTop\JTop.jar

It is a sight to know what is a thing.

It is recommended to use the upgraded version JConsole JVISUALVM.

About the use of JVISUALVM,->http://jiajun.iteye.com/blog/1180230

How to use Jconsole to observe and analyze the operation of Java program, and to perform debugging and tuning

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.