Java Performance monitoring under Linux

Source: Internet
Author: User

Java Performance monitoring under Linux

One, JVM heap memory usage monitoring

There are 3 ways to get thread dump:

1) using the Mbean in $java_home/bin/jcosole, to the mbean>com.sun.management>hotspotdiagnostic> operation >dumpheap, click Dumpheap button. The generated dump file is under the root directory of the Java application. 2) jmap-heap 1234 (1234 for process number)

3)cmd->JVISUALVM, remote connection, select Heap dump to generate heap dump log file

second, high CPU-intensive threads top+jastack 1) Top find out which process consumes high CPU21125 co_ad2 180 1817m 776m 9712S3.34.9 12:03.24java
5284co_ad 210 3028m 2.5g 9432S1.0 16.3 6629:44java
21994mysql 150 449m 88m 5072 s 1.0  0.6   67582:38mysqld                                                                                             
8657 co_sparr 19    0 2678m 892m 9220s  0.3   5.7 103:06.13 java
2) Top shift+h find out which thread consumes high CPU
first enter top, then press Shift+h
21233 co_ad2 150 1807m 630m 9492S1.3 4.00:05.12java
20503 co_ad2_s 150 1360m 560m 9176S0.3 3.60:46.72java
21134 co_ad2 150 1807m 630m 9492S0.3 4.0 0:00.72java                                                                                               
22673 Co_ad2   15   0 1807m 630m 9492s  0.3  4.0   0:03.12 java
Here we analyze 21233 of this thread, and note that This thread is part of the 21125 process.
    3) Jstack find information for this thread
Jstack [process]|grep-a 10 [thread 16]
i.e.: jastack 21125|grep-a 52f1 -A 10 means finding the following 10 rows of the row. 21233 Convert the calculator to 16 binary 52f1, note that the letter is lowercase.
Results:   
    1. "http-8081-11" daemon prio=10 tid=0x00002aab049a1800 NID=0X52BB in object.wait () [0x0000000042c75000]
    2. Java.lang.Thread.State:WAITING (on object monitor)
    3. At java.lang.Object.wait (Native Method)
    4. At Java.lang.Object.wait (object.java:485)
    5. At Org.apache.tomcat.util.net.jioendpoint$worker.await (jioendpoint.java:416)
third, Thread dump diagnose Java application problem

First find the process ID of the server , and then get the stack .

1)Ps–ef | grep java

2)kill-3 <pid> (after sending a sigquit signal to the Java application, there is usually a current thread dump output.) Output thread Dump Once, end the process and wait 3 seconds for the app to release resources)

(some Java application servers are running on the console, such as WebLogic, in order to facilitate access to threaddump information, when the WebLogic starts, it redirects its standard output to a file, using "Nohup./startweblogic. Sh > log.out & "command, execute" kill-3 <pid> ", Thread dump will be output to log.out. The thread dump of Tomcat is output to the command line console or to the logs catalina.out file. In order to reflect the dynamic change of thread state, we need to do more than three thread dump in succession, each interval 10-20s. ) 

Java Performance monitoring under Linux

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.