ThreadDump acquisition and analysis tool, and threaddump acquisition

Source: Internet
Author: User

ThreadDump acquisition and analysis tool, and threaddump acquisition

This section describes how to obtain ThreadDump and the analysis tools of ThreadDump.

1) in the Java program running session, use the following method:

Unix and Linux: CTRL -\

Windows: CTRL-BREAK

 

2) method 1) it is required that the Java program session be used. If it is not in the Java program session, what should we do?

Use the Jstack tool (jstack pid) provided in Jdk, which is applicable to both Windows and Linux. If you do not want to use this tool or have not installed it, you can also use the following command:

Linux: kill-3 pid

Windows: SendSignal.exe pid

It should be noted that the kill-3 pid is the shellprogram in linux, and sendsignal.exe used in Windows is a tool written by a cool named Louis. In fact, it simulates CTRL-BREAK.

Download the SendSignal.exe tool and the source code.

 

3) Sometimes, you may not have the process access permission. For example, in Linux, what if multiple users want to obtain ThreadDump?

You can only get it by writing a Java program. You can use JMX as a prompt.

There is a Threading # dumpAllThreads (boolean, boolean) method in the java. lang field. With this method, you can directly obtain the ThreadDump information.

 

4) if you want to see why your application is eating exceptionally high memory or getting stuck frequently, and so on, if you want to find out the cause, you can also use jconsole, jvisualvm, and jprofile to obtain and analyze ThreadDump and HeapDump. Of course, if you are a Java Developer, you can also use the Memory Analyzer Tool (MAT) provided by Eclipse to replace these tools.

Another tool, ThreadDumpViewer, is rare and is also a free tool for analyzing ThreadDump. This is also true.

 

5) If you are developing server applications or other O & M-related applications and want to provide you with ThreadDump information, you must use the program to control them, now it is more flexible:

A: You can use 3 ).

B: You can also use the Java Runtime API to execute the commands mentioned above 2.

 

Related Article

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.