Java problem diagnosis methods and tools

Source: Internet
Author: User

When a problem occurs in the online system, you need to record the current running status of the system. To sum up, you need to pay attention to the following aspects:
1. Load: -- top command
On Linux, execute top and other commands, pay attention to the overview of load, memory, CPU and other systems, and pay attention to the processes that consume a lot of CPU and memory.
Use top-H and sort the CPU by SHIFT + P to find the thread that currently occupies the most CPU. (Top-u BPM-h),-H display by thread, otherwise display by Process
Use PS-T <pid> | WC-L to find the number of threads of the currently running Java Process.

2. Thread dump -- jstack
Kill-3 <pid>
Jstack <pid> intercepts the thread stack of the current Java Process.

(Java thread dump related articles)

3. Memory -- jmap
Jmap-heap <pid> can obtain the current heap memory.
If you suspect there is a memory problem, you can also dump the heap object.
Java5: jmap-heap: format = B <pid>
Java6: jmap-dump: format = B, file = heap. Bin <pid>
Note: this operation has a great impact on the performance of the machine. In Java 6, you can also add-XX: heapdumppath =/home/NASDAQ/oom. hrof-XX: + heapdumponoutofmemoryerror to enable automatic memory dump during oom.

4. GC -- jstat
Jstat-gcutil <pid> to obtain the GC status of the current application.

5. Network Connection
Obtain the number of connections to each machine on the network.
Netstat-Na | grep established | awk '{print $5}' | awk-F: '{print $1}' | sort | uniq-c | sort-R
The preceding command execution result is:
Number of connected IP addresses
You can also use netstat to check the number of connections on a port.

6. Logs

Back up the current application log.

7. tools:

Heap dump analysis tool: Memory analyzer (MAT): http://www.eclipse.org/mat/ (using memory analyzer tool (MAT) Eclipse plug-in to Analyze memory leaks) thread dump analysis tool: lockness: http://lockness.plugin.free.fr/home.php

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.