Linux Java CPU 100%

Source: Internet
Author: User

1. Find the most resource-consuming process ID with top

[bin]# Top
Top-16:56:14 up 119 days, 6:17, 7 users, load average:2.04, 2.07, 2.09
tasks:256 Total, 1 running, 254 sleeping, 0 stopped, 1 zombie
Cpu (s): 5.0%us, 0.3%sy, 0.0%ni, 94.2%id, 0.4%wa, 0.0%hi, 0.0%si, 0.0%st
mem:8303056k Total, 7368528k used, 934528k free, 515232k buffers
Swap:www.qixoo.qixoo.com 16386260k Total, 27312k used, 16358948k free, 4670096k cached

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
5244 Root 0 1940m 1.3g 10m S 205.3 15.8 260:31.88 java
7991 Root 0 2336 1020 704 R 2.0 0.0 0:00.01 Top

2. Querying the Java processes that consume the most resources

[bin]# top-p 5244-h
top-16:56:00 up 119 days, 6:17, 7 users, Load average:2.05, 2.08, 2.09
tasks:67 Total, 2 running, sleeping, 0 stopped, 0 zombie
Cpu (s): 25.8%us, 0.2%sy, 0.0%ni, 73.4%id, 0.5%wa, 0.0%hi, 0.1%si, 0.0%st
mem:8303056k Total, 7369024k used, 934032k free, 515220k buffers
swap:16386260k Total, 27312k used, 16358948k free, 4670100k cached

PID USER PR NI VIRT RES SHR S%cpu%MEM time+ COMMAND
5920 Root 0 1940m 1.3g 10m R 98.6 15.8 121:55.29 java
5925 Root 0 1940m 1.3g 10m R 98.6 15.8 121:21.41 java
7985 Root 0 1940m 1.3g 10m S 3.3 15.8 0:00.10 java
5246 Root 0 1940m 1.3g 10m S 1.0 15.8 1:02.50 Java
5247 Root 0 1940m 1.3g 10m S 1.0 15.8 1:02.35 Java
5248 Root 0 1940m 1.3g 10m S 1.0 15.8 1:02.38 Java

3. Print Java stack information

Execute under the bin of the JDK

[bin]# jstack 5244 >stack.txt

4. Convert the javapid of the cost source to 16 binary (5920 ext. 1720 to Baidu: Decimal to hex)

The PID corresponds to nid (16 binary) in the stack

To find the nid=1720 problem in Stack.txt

"Longtimetask Thread" daemon prio=10 tid=0x40916400 nid=0x1720 runnable [0x412fe000]
Java.lang.Thread.State:RUNNABLE
At Com.zving.tk.service.CreatePaperService.createPaper (createpaperservice.java:143)
At Com.zving.tk.service.CreatePaperService.execute (createpaperservice.java:55)
At Com.zving.framework.messages.LongTimeTask.run (longtimetask.java:154)

5. Find source code based on specific issues

6. Also take a look at the heap

Execution in the bin directory of the JDK

Jmap-heap 5244

Jmap-histo 5244

Linux Java CPU 100%

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.