Created
February 11, 2015 14:18
-
-
Save jarrad/bed867bd232d3e811b91 to your computer and use it in GitHub Desktop.
Find the Java Thread that is hogging your CPU
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# first find the process using top | |
top -H | |
# find the java process | |
top - 15:32:53 up 1 day, 2:20, 1 user, load average: 1.28, 1.17, 1.18 | |
Tasks: 2355 total, 2 running, 2353 sleeping, 0 stopped, 0 zombie | |
Cpu(s): 26.4%us, 1.4%sy, 0.0%ni, 66.1%id, 5.7%wa, 0.0%hi, 0.2%si, 0.2%st | |
Mem: 16332248k total, 9613508k used, 6718740k free, 312148k buffers | |
Swap: 1048572k total, 0k used, 1048572k free, 1858716k cached | |
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND | |
29678 yourmom 20 0 5521m 23m 8112 R 94.6 0.1 7:00.19 java | |
# use jstack to dump the jvm threads | |
jstack 29678 | |
# the jvm provides the native pid as nid but in HEX: 29678 -> 0x73EE | |
# search for 0x73EE finds the thread hogging the CPU | |
"pool-1-thread-3" prio=10 tid=0x00009fa2ac0b5800 nid=0x73EE runnable [0x00009fa439df1000] | |
java.lang.Thread.State: RUNNABLE | |
at BossHog$Hog.run(BossHog.java:19) | |
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471) | |
at java.util.concurrent.FutureTask.run(FutureTask.java:262) | |
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145) | |
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) | |
at java.lang.Thread.run(Thread.java:744) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment