CPU100%, deadlocks, memory overflow of investigation

CPU100% of investigation

  1. Use top or pidstat command, view system performance data, you can find high CPU usage process. (Top command similar to Windows Explorer, it can show up in real-time status of the process, including the CPU information)
  2. Then use the top -H -p pid threads of this process is displayed. Capital input P may be sorted by thread CPU use ratio.
  3. Immediately use jstack pid> pid.log Dump the thread stack to the log file.
  4. View through the stack of logs problem.

In the top run-time, you can switch on or off by pressing the "H" key to the thread view mode.

top -H

Here Insert Picture Description
Let the top output of a particular process and check the status of threads running within this process:

top -H -p <pid>

Here Insert Picture Description

Deadlock positioning method

  1. As there is a system running log, first analyze log information.
  2. Jstack use other tools to obtain the thread stack, command format is: jstack. Information jstack get run java program java stack and the native stack. It can easily learn the operation of the current thread, as follows:
    Here Insert Picture Description
  3. Thead dump analysis based on some of the current state of the operation of the various threads, focusing on the thread: Deadlock, Waiting on condition (waiting for resources), Waiting on monitor entry (waiting to acquire a monitor), Blocked (blocking)
  4. Some of the stack may be blocked because it needs to wait for the end of the previous thread of execution can perform, you must first determine dependencies.
  5. Further investigation deadlock.
  6. JConsole even limited deadlock detection in the graphical interface.

Deadlock:
https://blog.csdn.net/zbajie001/article/details/80045710
https://www.cnblogs.com/wuchanming/p/7766994.html

Memory overflow of troubleshooting steps

The main tools: jmap, mat tool.

step:

  1. Export memory image file (two ways).
  2. Import .hprof down to the files in the MAT tool for analysis.
  3. MAT analysis tool has a memory for the largest class method where, further analysis to observe where an object class that there is a problem.

Export memory-mapped files

Exporting a memory image file (two ways):
. 1, the VM parameter method, memory overflow automatic export
// set automatically exported to the current path, and export

-XX:+HeapDumpOnOutOfMemoryError
-XX:HeapDumpPath=./

2, jmap command, run the corresponding jar process, jps find the process ID, and then set the export format jmap

jps
jmap -dump:format=b,file=heap.hprof <pid>

Here Insert Picture Description

If the former is about to overflow, the second option, if it is already running out of memory, the first election (which is prevention).

Import .hprof down to the files in the MAT tool for analysis.

Here Insert Picture Description

Obviously, MAT analysis tool has a maximum occupancy of memory class where the method, further analysis to observe where an object class that there is a problem.

Here Insert Picture Description

https://blog.csdn.net/qq_41797857/article/details/91383000

Published 67 original articles · won praise 32 · views 60000 +

Guess you like

Origin blog.csdn.net/weixin_43751710/article/details/104900890