Analyze the reasons why java occupies a large amount of CPU resources in CentOS

Source: Internet
Author: User
Tags high cpu usage

Analyze the reasons why java occupies a large amount of CPU resources in CentOS

1. Use the top command to find the Java Process PID. Here, the PID is 16871.

2. After finding the process, you need to locate the specific thread or code. First, the thread list is displayed and sorted by the threads with high CPU usage:
Ps-mp 16871-o THREAD, tid, time | sort-rn

The result is as follows:
USER % CPU PRI SCNT WCHAN USER SYSTEM TID TIME
Root 90.5 19---9521 01:16:48
Root 90.1 19---952201: 02: 16

We found the thread with the highest time consumption of 9521, and it took more than one hour to occupy the CPU.

Convert the required thread ID to the hexadecimal format:
Printf "% xn" 9521
2531

Finally, run the jvm command to print the stack information of the thread:
Jstack 16871 | grep 2531-A 30

In this way, we can find the code that occupies java and cpu resources. Next we have to analyze the reason for code execution.

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.