Java comes with GUI performance monitoring tools Jconsole and JISUALVM Introduction

Source: Internet
Author: User

Original link:http://blog.csdn.net/chendc201/article/details/229055031 Jconsole1.1 Introduction and connection

Jconsole is a JMX-based GUI tool for connecting a running JVM, which is a simple performance monitoring tool that comes with Java. The following is an example of tomcat monitoring, which leads you to familiarize yourself with the Jconsole tool.

Step 1, under the Dos/bash command, enter: Jconsole;

Step 2, select Apache in the popup dialog box and click Connect (assuming your tomcat is up);

  

Next, you can use Jconsole to do some simple performance monitoring.

1.2 Module Introduction 1.2.1 Overview

  

1. Overview interface, mainly shows the heap memory usage, the number of active threads, the number of load classes, CPU utilization Four parameters of the summary, you can use the drop-down box to customize the display of the time range;

2. If the image of the heap memory has been rising and does not fall, then it is doubtful whether the memory leaks, the robust project due to the existence of GC, so its rise and fall amplitude should be similar;

3. The CPU's image law is roughly the same as the heap memory.

1.2.2 Memory

  

1. The detailed memory diagram of the monitored program is shown;

2. Focus on point 1: Click the GC button on the right to notify the JVM to garbage collection, in essence, the garbage collection queue priority increased;

3. Focus point 2:GC Time shows the timing, algorithm, and number of recoveries for each collection, 7.619 seconds is used, copy represents the garbage collection mechanism of the replication algorithm, Marksweepcompact represents the garbage collection mechanism of the token-purge-compression algorithm, 1426 Collections indicates the number of recoveries;

4. The pattern in the lower right corner, the heap memory area includes: The Young Generation Eden space, the surviving generation survivor space and the old age tenured Gen;non-heap memory area includes: Code cache and persistent generation Perm Gen , you can switch by changing the drop-down box or by clicking the graphic directly.

1.2.3 Threads

  

1. Peak indicates the maximum number of threads, which can be changed by changing the maxthreads under <tomcat_home>/conf/server.xml;

2. After clicking on the specific thread, we can see the detailed invocation of the method stack;

3. Click Detect deadlock to detect if there is a deadlock.

1.2.4 Classes

  

Focus: The number of classes changes.

1.2.5 VM Summary

  

Focus 1: The above columns are a summary of the system and the project;

Focus 2: The first item in the bottom column is the JVM parameter set by Tomcat, and if you want to know if the parameters you set have been successfully enabled, look here.

1.2.6 MBeans

  

The attention point 1:attributes shows the details of the bean;

  

Focus 2:operations Show all the methods of the bean, you can click on the button to trigger the method, but the individual is not recommended to do so, should be triggered through the uniform entrance of the program.

2 JVisualVM2.1 Introduction and connection

JVISUALVM is NetBeans's profile subproject, which has been brought in JDK6.0 Update 7 (Bin/jvisualvm.exe), is capable of monitoring threads, memory conditions, viewing the method's CPU time and in-memory objects, objects that have been GC, Reverse-View the allocated stack (for example, 100 string objects are assigned by which objects).

Step 1, if you have a Tomcat project on hand already started, enter in the Bash/dos: JVISUALVM, tap enter;

Step 2, select Tomcat, double click to start monitoring, on the initial page we can see some summary information and JVM parameters.

  

2.2 Module Introduction 2.2.1 Monitor

  

Focus 1: The button "Perform GC" notifies the JVM to increase the priority of garbage collection actions;

Focus 2: "Daemon" thread refers to the JVM's daemon thread, which is popularly understood as the JVM's system process;

Focus 3: The button "heap dump" generates a heap memory snapshot, which explains the use of heap dump in detail below.

2.2.1.1 Heap Dump 1) Summary

  

Focus 1: Red box marked by the arrows, you can click on the order to switch back and forth window;

Concern 2: "Inspect" inspection Office can query the largest object, the number can be customized;

Focus point 3: Click "Show Threads" to display the thread details as follows:

  

The focus points 1:timed_waiting and runnable indicate the thread running state;

The focus 2:daemon indicates that this thread is a daemon thread, such as no tag daemon means that it is a user thread, such as the main thread;

The focus 3:prio represents the priority of the thread, and the higher the number in the Java thread the higher the priority, the value from 1 to 10, the default is 5;

Focus 4: Click on the related class marked Blue, you can view the details in the instances interface;

2) Instances

  

Attention point 1: The top right corner of the three buttons can be customized interface;

Focus 2: Click "Compute retained Sizes" to calculate the reserved size for each field, in short, the byte value it occupies;

Attention point 3: The lower right corner of the red box marked out, different graphics represent different roles;

3) Classes

  

Focus on point 1: The lower left corner can filter the display view via filter;

Focus 2: Right-click a class to display it in the instances interface to see its details;

Attention point 3: Click on the upper right corner of the red box can be compared with another memory snapshot, in the comparison view can be seen in the increase and decrease of each class;

4) OQL Console

  

Focus on point 1: Click Saved Queries, select the specific query instance, click on execute can be queried, save button can save your query statement;

Focus 2: Compare the use of PermGen analysis statements;

2.2.2 Threads

  

Attention point 1: Thread color from green, purple, yellow, red, respectively, representing the operation, hibernation, waiting and deadlock;

The focus 2:timeline shows the thread situation in the timeline, table is displayed in a table, and details show the threading situation in detail in graphical + tabular format. Of course you can also select a single thread to display, by clicking the drop-down box to achieve;

Focus 3: Click Thread Dump to generate a thread snapshot, which is similar to show threads in 2.2.1.1 Heap dump 1) Summary, and is not explained here.

Introduction to 2.2.3 Sampler2.2.3.1 Sampler

1. The settings can be used to set the sampling source of the CPU and the memory refresh time;

2. Click on the CPU or memory to start monitoring, click on stop to stop sampling;

2.2.3.2 CPU 1) CPU samples

  

Focus point 1: Click Thread dump to generate a thread snapshot;

Focus 2: Click Snapshot to generate a snapshot of the thread, which contains the call tree for all threads and its hotspot compilation, as shown in:

  

2) Thread CPU time

Focus: After clicking the Deltas button, you can record the changes in the thread, which is somewhat similar to Jprofiler's "Mark current Values".

2.2.3.3 Memory 1) Heap histogram

  

The function of 1:deltas, Peform GC, and Heap dump is similar to the above;

Focus 2: Clicking Snapshot will generate the following memory snapshot, which mainly shows the memory information of the classes in the heap memory:

  

2) PermGen histogram

  

Figure is the memory condition of the persistent generation.

3) Perthread Allocations

  

Figure is the memory distribution of each thread.

2.2.4 Profiler2.2.4.1 CPU

  

The profiler differs from the sampler in that it is a real-time monitoring of the program, while sampler is only a statistical sample for a period of time.

In the CPU function module we can see the usage time of each hotspot compilation method.

2.2.4.2 Thread

  

Real-time monitoring of the current surviving objects.

3 How to turn on remote monitoring parameter setting in 3.1 tomcat

The Windows system adds the following configuration to the Catalina_home/bin/setenv.bat:

Set java_opts=%java_opts%-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.port= "9005"- Dcom.sun.management.jmxremote.authenticate= "false"-dcom.sun.management.jmxremote.ssl= "false"

The Linux system adds the following configuration to the catalina_home/bin/setenv.sh:

Export java_opts= "$JAVA _opts-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.port= ' 9005 '- Dcom.sun.management.jmxremote.authenticate= ' false '-dcom.sun.management.jmxremote.ssl= ' false ' "

1) '-dcom.sun.management.jmxremote ' means enable Java management Extensions (Java Management Extension) technology, or JMX. JMX defines the architecture, design patterns, application interfaces, and services of applications and network management and monitoring in the Java programming language. JMX is typically used to monitor the operating state of a system or to manage certain aspects of the system, such as emptying the cache, reloading the configuration file, and so on.

2) ' 9004 ' indicates the port number of this JMX service;

3) ' Authenticate ' indicates false without account password verification, such as true (Enable Account password Authentication), the following configuration should be added:

> Copy the ' jmxremote.password.template ' file under Jre_home/lib/management, such as ' Jmxremote.password ', Remove the comments from the Monitorrole and controlrole at the bottom of the new file that you copied.

The value of > Monitorrole represents the Read password, controlrole represents the read and write password, please change the value of both to the password you want;

> Modify the setenv.sh configuration (Windows please modify. bat) as follows:

Export java_opts= "$JAVA _opts-dcom.sun.management.jmxremote-dcom.sun.management.jmxremote.port= ' 9005 '- Dcom.sun.management.jmxremote.password.file=pwdfilepath-dcom.sun.management.jmxremote.ssl= ' false ' "

> ' Set file permissions so this only can read and write the password file ', this copy of the password files need to be set to only the owner has read and write permissions, otherwise tomcat will not be normal Start

4)-dcom.sun.management.jmxremote.ssl= ' false '

Configuration of the 3.2 jconsole configuration 3.3 JVISULVM

(RPM) Java comes with GUI performance monitoring tools Jconsole and JISUALVM Introduction

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.