Original source:Http://www.blogjava.net/hankchen
Phenomenon:
Deploying Java Web Applications in Tomcat, the Java process that appeared after Tomcat for a period of time continued to consume up to 100% of the CPU, causing Web program access to be blocked.
Possible cause Analysis:
It is possible that the program is actually doing data calculations, or the program enters a dead loop;
Workaround:
1. First, use top to view the process ID that consumes the CPU
2. Re-use Ps-ef | grep PID locates the specific process body, such as whether it is a tomcat-initiated Java program
3, with PS-MP pid-o thread,tid,time print out the process of the thread consumption of CPU
Found the most time-consuming thread 28802, taking up CPU time two hours faster!
4. Next, convert the required thread ID to 16 binary format:
printf "%x\n" tid
5. Finally, the stack information of the print thread:
Jstack PID |grep tid-a 30
Locate the code that has the problem and analyze the code snippet in the specific function for possible dead loops.
Typically, the problem occurs in a loop code fragment, such as while.
Tomcat+java Web program continues to account for CPU problem debugging