Correlating Linux top output with java stack trace from a thread dump

Writing by on Thursday, 21 of February , 2013 at 12:23 am

Using the top -H command to show you the thread ids, and from the thread dump, you can correlate the thread that’s taking CPU time.

For example the stack trace will show you the ID in hex format and the top will show you the thread PID in decimal format.

Notice that nid=0x6c21 (top -H) is the same as 27681 (from the thread dump).

Here’s a thread dump snippet

“http-bio-/” daemon prio=10 tid=0x000000004c433800 nid=0x6c21 runnable [0x00000000644b9000]
INFO | jvm 1 | 2013/02/20 11:51:57 | java.lang.Thread.State: RUNNABLE
INFO | jvm 1 | 2013/02/20 11:51:57 | at java.util.HashMap.put(

Here’s the output of top -H

[root@myserver bin]# top -H

top – 15:56:17 up 5 days, 5:16, 8 users, load average: 2.16, 2.25, 3.28
Tasks: 1038 total, 3 running, 1035 sleeping, 0 stopped, 0 zombie
Cpu(s): 12.8%us, 0.1%sy, 0.0%ni, 87.1%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 37043972k total, 35569196k used, 1474776k free, 45720k buffers
Swap: 12586916k total, 228k used, 12586688k free, 18998952k cached
3.00 00:04:50
27409 shivdev 25 0 11.6g 10g 16m R 99.9 30.7 1305:02 java
27681 shivdev 25 0 11.6g 10g 16m R 99.9 30.7 1304:37 java

Leave a comment

Category: Java,Linux

Shivdev Kalambi's Blog

Shivdev Kalambi is a Software Development Manager, previously a Principal Software Engineer at ArcSight/HP. With over 16 years' experience in software development, he's worked on several technologies and played different roles and contributed to all phases of projects. Non-tech activies include Ping-pong, Rock Climbing and Yoga at PG, Golf, Skiing, Swimming & a beer enthusiast.