2013-05-31 44 views
4

我想調查爲什麼我的jboss佔用了600%CPU(在CentOS 5上運行)。頂部-H顯示幾個線程ID不會出現在jstack輸出

我運行top -H並嘗試將結果與jstack輸出進行比較。大多數來自頂端的線程ID出現在jstack的輸出中,但不幸的是佔用大部分CPU的線程並未在那裏列出。

由於輸出很長,我只列出了一部分。

$top -b -n1 -H -p <jboss pid> 

top - 08:04:58 up 73 days, 19:50, 1 user, load average: 5.72, 5.97, 5.95 
Tasks: 128 total, 6 running, 122 sleeping, 0 stopped, 0 zombie 
Cpu(s): 63.6%us, 1.7%sy, 0.0%ni, 34.2%id, 0.3%wa, 0.0%hi, 0.2%si, 0.0%st 
Mem: 32946160k total, 32545228k used, 400932k free, 86776k buffers 
Swap: 34996216k total,  136k used, 34996080k free, 21577176k cached 

    PID USER  PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND                               
12908 jboss  16 0 9488m 8.6g 18m S 71.5 27.4 146:45.68 java                                
12903 jboss  16 0 9488m 8.6g 18m S 69.5 27.4 146:36.08 java                                
12904 jboss  16 0 9488m 8.6g 18m S 69.5 27.4 146:39.63 java                                
12905 jboss  16 0 9488m 8.6g 18m S 69.5 27.4 146:44.46 java                                
12906 jboss  16 0 9488m 8.6g 18m S 69.5 27.4 146:53.94 java                                
12907 jboss  16 0 9488m 8.6g 18m S 69.5 27.4 146:39.18 java                                
12914 jboss  16 0 9488m 8.6g 18m R 27.8 27.4 36:26.64 java                                
12901 jboss  25 0 9488m 8.6g 18m S 0.0 27.4 0:00.00 java                                
12902 jboss  25 0 9488m 8.6g 18m S 0.0 27.4 0:00.05 java                                
12909 jboss  23 0 9488m 8.6g 18m S 0.0 27.4 76:34.09 java                                
12910 jboss  23 0 9488m 8.6g 18m S 0.0 27.4 76:33.49 java                                
12911 jboss  15 0 9488m 8.6g 18m S 0.0 27.4 257:10.35 java                                
12915 jboss  15 0 9488m 8.6g 18m S 0.0 27.4 0:06.63 java                                
12916 jboss  15 0 9488m 8.6g 18m S 0.0 27.4 0:19.61 java 
more lines.... 

的jstack outpout是如下

# /usr/java/jdk1.6.0_33/bin/jstack -F 3362 

Deadlock Detection: 

No deadlocks found. 

Thread 13055: (state = BLOCKED) 
- java.lang.Object.wait(long) @bci=0 (Interpreted frame) 
- java.lang.Object.wait() @bci=2, line=485 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.await() @bci=8, line=415 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.run() @bci=11, line=441 (Interpreted frame) 
- java.lang.Thread.run() @bci=11, line=662 (Interpreted frame) 


Thread 12996: (state = BLOCKED) 
- java.lang.Object.wait(long) @bci=0 (Interpreted frame) 
- java.lang.Object.wait() @bci=2, line=485 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.await() @bci=8, line=415 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.run() @bci=11, line=441 (Interpreted frame) 
- java.lang.Thread.run() @bci=11, line=662 (Interpreted frame) 


Thread 12994: (state = BLOCKED) 
- java.lang.Object.wait(long) @bci=0 (Interpreted frame) 
- java.lang.Object.wait() @bci=2, line=485 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.await() @bci=8, line=415 (Interpreted frame) 
- org.apache.tomcat.util.net.JIoEndpoint$Worker.run() @bci=11, line=441 (Interpreted frame) 
- java.lang.Thread.run() @bci=11, line=662 (Interpreted frame) 

多個堆疊....

jstack輸出的線程ID也出現在top輸出而是從線程ID頂部是CPU佔用最多的(1903-1908)不會出現在jstack的輸出中。

我認爲這些可以是GC線程,但我找不到任何證明這一點。

任何想法爲什麼我沒有看到jstack中的所有線程,或者我能做些什麼來查看丟失的線程?

+0

有你有沒有找到一個答案?我目前有同樣的問題。 – jpints14

回答

1

嘗試運行jboss所有者下的jstack。這樣你會得到更多的線程作爲輸出。通過發行

jstack -l 12345 

"Service Thread" #9 daemon prio=9 os_prio=0 tid=0x00007f976c0d3000 nid=0x1f56a runnable [0x0000000000000000] 
    java.lang.Thread.State: RUNNABLE 

    Locked ownable synchronizers: 
     - None 

注意NID是線程ID的十六進制表示從上-H