首页 > 代码库 > what linux java cpu 100% ?

what linux java cpu 100% ?

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

[ 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 www.qixoo.qixoo.com root 15 0 2336 1020 704 R 2.0 0.0 0:00.01 top

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

[ 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下执行

[ 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

what linux java cpu 100% ?