Tomcat + java web programs continue to occupy cpu issues for debugging

Source: Internet
Author: User

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.

Related Article

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.