Tomcat + java web programs continue to occupy cpu issues for debugging
Symptom:
Deploy Java web applications in tomcat. After a while, the java Process of tomcat continues to occupy up to 100% of the cpu, leading to blocked web application access.
Possible Cause Analysis:
The program may indeed perform data computing; or the program may enter an endless loop;
Solution:
1. First use top to view the cpu-consuming process id
2. Use the ps-ef | grep PID to locate the specific process subject, for example, whether it is a java program started by tomcat.
3. Use ps-mp pid-o THREAD, tid, and time to print the cpu usage of threads in the process.
We found the thread with the highest time consumption of 28802, and it took almost two hours to use the CPU!
4. Second, convert the required thread ID to the hexadecimal format:
Printf "% x \ n" tid
5. Finally, print the stack information of the thread:
Jstack pid | grep tid-A 30
Locate the problematic code and analyze whether the code segment in a specific function may have an endless loop.
Usually the problem occurs in loop code snippets such as while and.