The reason why Java consumes a lot of CPU resources in CentOS __centos

Source: Internet
Author: User

1, using the top command to find the PID of the Java process, I found here the PID is 16871.

2, after you locate the process, locate the specific thread or code, first display the list of threads, and sort by the CPU-intensive thread:
PS-MP 16871-o Thread,tid,time | Sort-rn

The results appear as follows:
User%cpu PRI SCNT wchan user SYSTEM TID time
Root 90.5 19––––9521 01:16:48
Root 90.1 19––––9522 01:02:16

Found the most time-consuming thread 9521, CPU time for 1 hours.

Converts the required thread ID to a 16-in-system format:
printf "%xn" 9521
2531

Finally, use the JVM command to print the thread's stack information:
Jstack 16871 |grep 2531-a 30

This will find the code that occupies the JAVA,CPU resource, and then you have to analyze the reason for the execution of the code.

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.