CPU100% of investigation
- 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)
- Then use the top -H -p pid threads of this process is displayed. Capital input P may be sorted by thread CPU use ratio.
- Immediately use jstack pid> pid.log Dump the thread stack to the log file.
- 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
Let the top output of a particular process and check the status of threads running within this process:
top -H -p <pid>
Deadlock positioning method
- As there is a system running log, first analyze log information.
- 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:
- 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)
- 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.
- Further investigation deadlock.
- 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:
- Export memory image file (two ways).
- Import .hprof down to the files in the MAT tool for analysis.
- 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>
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.
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.
https://blog.csdn.net/qq_41797857/article/details/91383000