How to use Jconsole to observe and analyze the running of Java program and adjust the error of debugging _java

Source: Internet
Author: User
Tags garbage collection memory usage account security visualvm 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 a GUI shell. You can easily use Jconsole (or, perhaps, its more high-end "close cousin" VISUALVM) to monitor Java application performance and track code in Java.

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

When the profiling 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 appear asking for the URL of a process to connect, or a number of different local Java processes (sometimes including the jconsole process itself) to connect. As shown in the figure:

To analyze that program, double-click the process.

Third, how to set the Java program Runtime can be jconsolse connection analysis

1. The local program (relative to the computer on which Jconsole is turned on) can be opened locally by a jconsole connection without setting any parameters (Java SE 6 does not need to be set at first, before it needs to set Run-time parameters- Dcom.sun.management.jmxremote)
2. No authentication connection (The following setting indicates: The connection port is 8999, 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 you take into account security factors, need authentication, need a secure connection, can also be done. Reference: http://download.oracle.com/javase/6/docs/technotes/guides/management/agent.html

Four, jconsole How to connect the remote machine Java program (for example)

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

Copy Code code 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 to connect

You can use the command directly:

Copy Code code as follows:

Jconsole.exe 192.168.0.181:8999

You can also select the remote process-> Enter the remote host IP and port number-> Click "Connect" in the Jconsole interface that has already been opened-> New connection->


Then you'll enter the analysis interface:

Performance analysis

Here's 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 Load Information
*VM Summary: * Display Java VM information
Mbeans: Display Mbeans.

Then you'll enter the analysis interface:

Overview

The outline is very simple nothing to say, take a look at it, but it is worth mentioning the right click on the map to save data to the CSV file, you can use other tools to analyze the data later.

Memory

This is more valuable, see heap memory, not heap memory, memory pool status of total memory allocation and usage, and different GC garbage collection times and times. The GC can be viewed manually for memory changes.

This is useful when analyzing Java memory issues, you learn the JVM memory model, and then you find that every value here is meaningful.

GC Algorithms and parameters have a significant impact on performance, note garbage collection times, time, and partial GC and full GC, adjust the different GC and GC parameters you use, and then observe in this view for good performance.

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


About GC, you can 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 filter out the threads you want to observe in the filter bar below). Clicking on a display displays the name of the thread, the status, the number of blocks and waits, and the stack's information.

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

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

Class

There's nothing to say.

VM Summary

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

Mbean

There can be some extra action here.

Plug - ins

Jconsole-pluginpath C:\Java\jdk1.6.0_22\demo\management\JTop\JTop.jar


A look at it, is a thing.

It is recommended to use the upgraded version Jconsole namely JVISUALVM.

About the use of JVISUALVM,-> http://www.jb51.net/article/77131.htm

Resources:

    1. Monitoring and Management Using jconsole : http://download.oracle.com/javase/6/docs/technotes/ guides/management/jconsole.html
    2. http://download.oracle.com/javase/6/docs/technotes/guides/management/ agent.html monitoring and Management Using JMX technology:http://download.oracle.com/javase/6/docs/technotes/guides/ management/agent.html
    3. Eclipse launcher for visualvm:http://visualvm.dev.java.net/eclipse-launcher.html
    4. Tuning Garbage Collection with the 5.0 Java[tm] Virtual machine:http://www.oracle.com/technetwork/java/gc-tu ning-5-138395.html

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.