码迷,mamicode.com
首页 > 编程语言 > 详细

linux java cpu 100%

时间:2016-11-09 11:01:21      阅读:217      评论:0      收藏:0      [点我收藏+]

标签:资源   pap   去百度   use   buffers   map   查询   ram   daemon   

1.用top找到最耗资源的进程id

[root@localhost 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: 16386260k total, 27312k used, 16358948k free, 4670096k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND  
5244 root 15 0 1940m 1.3g 10m S 205.3 15.8 260:31.88 java  
7991 root 15 0 2336 1020 704 R 2.0 0.0 0:00.01 top 

2.查询最消耗资源的java进程

[root@localhost 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, 65 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 18 0 1940m 1.3g 10m R 98.6 15.8 121:55.29 java  
5925 root 25 0 1940m 1.3g 10m R 98.6 15.8 121:21.41 java  
7985 root 15 0 1940m 1.3g 10m S 3.3 15.8 0:00.10 java  
5246 root 15 0 1940m 1.3g 10m S 1.0 15.8 1:02.50 java  
5247 root 15 0 1940m 1.3g 10m S 1.0 15.8 1:02.35 java  
5248 root 15 0 1940m 1.3g 10m S 1.0 15.8 1:02.38 java 

3.打印java 栈 信息

在jdk的bin下执行

[root@localhost bin]# jstack 5244 >stack.txt

 

4.将耗资源的javaPID转换为16进制(5920转1720 去百度找 :十进制转十六进制)

PID 对应 堆栈中的nid(16进制)

去stack.txt 中查找nid=1720的问题

"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.根据具体问题查找源代码 

 

6.同时要看一下堆的情况

在jdk的bin目录执行

jmap - heap 5244

jmap -histo 5244

linux java cpu 100%

标签:资源   pap   去百度   use   buffers   map   查询   ram   daemon   

原文地址:http://www.cnblogs.com/zouhao510/p/6045328.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!