Linux Java thread 100% problem locating method

Source: Internet
Author: User

I. BACKGROUND

The development of the Internet today, many problems will be encountered in the production, if one day found that the system resources in the CPU occupied 100%, has been high, then we need to query the problem.

Second, the solution of ideas

1. View that Java process occupies the most, top command

[Email protected] test]# top-h

650) this.width=650; "Src=" https://s4.51cto.com/wyfs02/M00/8D/88/wKiom1igUPnTuolTAAEeg-_h5wI991.png-wh_500x0-wm_ 3-wmp_4-s_4244281010.png "title=" qq picture 20170212201121.png "alt=" Wkiom1igupntuoltaaeeg-_h5wi991.png-wh_50 "/>

2, can obviously see the PID 29003 Java process occupies the highest cup, has occupied 95.5%, can be further viewed according to the process number of the thread of the process. Displays the CPU resource consumption for each thread in the process.

[Email protected] test]# top-h-P 29003


650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8D/88/wKiom1igUzrBssXzAAEhWYfxICw505.png-wh_500x0-wm_ 3-wmp_4-s_4150159320.png "title=" qq picture 11111.png "alt=" Wkiom1iguzrbssxzaaehwyfxicw505.png-wh_50 "/>

3. After finding the most occupied PID29003, use Jstack to print the thread stack information to the stack file, such as:

[Email protected] atm]# jstack-l-F 29003 >29003.stack

650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/8D/86/wKioL1igVCTRuQrGAABXlzBQjfU983.jpg-wh_500x0-wm_ 3-wmp_4-s_1083867634.jpg "title=" qq20222222.jpg "alt=" Wkiol1igvctruqrgaabxlzbqjfu983.jpg-wh_50 "/>

At this point, the thread stack information has been printed into the 29003.stack file, you can use the cat and other commands to view the file.

4, find 29003 of the front and back 20 lines of information (20 lines not enough can be 50 lines or more), and show out:

[[email protected] test]# cat 29003.stack |grep-a 20 ' 29003 '

650) this.width=650; "Src=" https://s2.51cto.com/wyfs02/M01/8D/86/wKioL1igVW6TXWR2AAGRE6jRZgU349.jpg-wh_500x0-wm_ 3-wmp_4-s_3412072441.jpg "title=" qq23333.jpg "alt=" Wkiol1igvw6txwr2aagre6jrzgu349.jpg-wh_50 "/>


As shown, you can pinpoint exactly which method in the class is causing the problem to occur, and then resolve it according to the code one by one.

This article is from the "Yao Sea" blog, please be sure to keep this source http://tl2011.blog.51cto.com/6006611/1897118

Linux Java thread 100% problem locating method

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.