SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Thread Dump Troubleshooting Jie Chen March 2010
©2010 Oracle Corporation Agenda Why & When to take Thread Dump How to take Thread Dump Thread State Analyzing Case Study
©2010 Oracle Corporation Why & When to take Thread Dump What / Why A snapshot of all threads in Java application Showing each thread’s state / health When Bad performance System hangs CPU High Usage
How to take Thread Dump Weblogic Windows: (Note 659452.1) Edit *.cmd to output the dump Press Ctrl+Break Unix/Linux: (Note 659452.1) Edit *.sh Get PID by “ps -ef|grep java” “Kill -3 <PID>” ©2010 Oracle Corporation E.g, startAgile.cmd %JAVA_HOME%inava %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME% … weblogic.Server>c:/temp/mydump.log
How to take Thread Dump Oracle AS Windows: (Note 437464.1) Get PID (Process ID) by “opmnctl status –l” Run thdump utility by “thdump <PID>” Unix/Linux (Note 361729.1) Get PID by “opmnctl status -l” Run “kill -3 <PID>”   Output written to OC4J~home~default-island~1 (default) ©2010 Oracle Corporation
Thread State Running Blocked / Waiting for Monitor Entry Waiting / Timed Waiting Sleeping / Waiting on Condition ©2010 Oracle Corporation
Thread State Running Blocked / Waiting for Monitor Entry Waiting / Timed Waiting Sleeping / Waiting on Condition ©2010 Oracle Corporation
Analyzing Understand Application Take more Dumps in a Short Duration Eliminate Running / Idle Threads Analyze Blocked / Waiting Threads ©2010 Oracle Corporation
Case Study 1 CPU High Usage Get Thread Dump first Get TID (Thread ID) Process Explorer (Windows)       “ps –eL|grep java” (Unix/Linux) 3.   Convert TID to hexadecimal 4.   Find out the problem stack ©2010 Oracle Corporation
Case Study 2 Classic Deadlock One thread is blocked to acquire resource which is hold by other blocked thread(s) ©2010 Oracle Corporation =================================================== "Thread-1":         at zigzag.threaddump.demo.TestDeadLock.run(TestDeadLock.java:27)         - waiting to lock <0x22a15c98> (a java.lang.Object)         - locked <0x22a15ca0> (a java.lang.Object)         at java.lang.Thread.run(Unknown Source) "Thread-0":         at zigzag.threaddump.demo.TestDeadLock.run(TestDeadLock.java:16)         - waiting to lock <0x22a15ca0> (a java.lang.Object)         - locked <0x22a15c98> (a java.lang.Object)         at java.lang.Thread.run(Unknown Source) Found 1 deadlock. System   Hangs
Case Study 3 Resource Contention Two or more threads are fighting for the same resource(s) ©2010 Oracle Corporation "Thread-2" prio=6 tid=0x02b48000 nid=0x120c waiting for monitor entry [0x02f1f000] java.lang.Thread.State: BLOCKED (on object monitor)         at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:11)         - waiting to lock <0x22a15e30> (a java.lang.Object)         at java.lang.Thread.run(Unknown Source) "Thread-1" prio=6 tid=0x02b46c00 nid=0xc3c waiting for monitor entry [0x02ecf000] java.lang.Thread.State: BLOCKED (on object monitor)         at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:11)         - waiting to lock <0x22a15e30> (a java.lang.Object)         at java.lang.Thread.run(Unknown Source) "Thread-0" prio=6 tid=0x02b45800 nid=0x49c waiting on condition [0x02e7f000] java.lang.Thread.State: TIMED_WAITING (sleeping)         at java.lang.Thread.sleep(Native Method)         at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:12)         - locked <0x22a15e30> (a java.lang.Object)         at java.lang.Thread.run(Unknown Source) Bad Performance
Case Study 4 Out of Threads No more room for additional threads running ©2010 Oracle Corporation E.g. 5 tasks need to run but only 2 threads are allowed concurrently. Task 2,3 and 4 have to wait until Task 0 and 1 finish.  "Zigzag_ThreadPool-1" prio=6 tid=0x02b47000 nid=0x133c runnable [0x02ecf000] java.lang.Thread.State: RUNNABLE         at zigzag.threaddump.demo.ThreadPoolTest$1.run(ThreadPoolTest.java:44)         at zigzag.threaddump.demo.ThreadPool$PooledThread.run(ThreadPoolTest.java:185) "Zigzag_ThreadPool-0" prio=6 tid=0x02b46400 nid=0x11d0 runnable [0x02e7f000] java.lang.Thread.State: RUNNABLE         at zigzag.threaddump.demo.ThreadPoolTest$1.run(ThreadPoolTest.java:44)         at zigzag.threaddump.demo.ThreadPool$PooledThread.run(ThreadPoolTest.java:185) Bad Performance
Case Script CPU High Usage Classic Deadlock Resource Contention Out of Threads ©2010 Oracle Corporation
Third Part Utility Process Explorer http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx TDA (Thread Dump Analyzer) https://tda.dev.java.net ©2010 Oracle Corporation
©2010 Oracle Corporation Q/A

Weitere ähnliche Inhalte

Was ist angesagt?

Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsDror Bereznitsky
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsAndrei Pangin
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkDror Bereznitsky
 
Explore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav MishraExplore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav MishraSopra Steria India
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayodnoklassniki.ru
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in JavaAllan Huang
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemWill Iverson
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsAndrei Pangin
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMashleypuls
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVModnoklassniki.ru
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?Andrei Pangin
 
Николай Папирный Тема: "Java memory model для простых смертных"
Николай Папирный Тема: "Java memory model для простых смертных"Николай Папирный Тема: "Java memory model для простых смертных"
Николай Папирный Тема: "Java memory model для простых смертных"Ciklum Minsk
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101Tim Penhey
 
JDK not so hidden treasures
JDK not so hidden treasuresJDK not so hidden treasures
JDK not so hidden treasuresAndrzej Grzesik
 
Core Java Programming Language (JSE) : Chapter XII - Threads
Core Java Programming Language (JSE) : Chapter XII -  ThreadsCore Java Programming Language (JSE) : Chapter XII -  Threads
Core Java Programming Language (JSE) : Chapter XII - ThreadsWebStackAcademy
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test toolsAllan Huang
 
Real World Mocking In Swift
Real World Mocking In SwiftReal World Mocking In Swift
Real World Mocking In SwiftVeronica Lillie
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF qualssnyff
 
How & why-memory-efficient?
How & why-memory-efficient?How & why-memory-efficient?
How & why-memory-efficient?Tier1 app
 

Was ist angesagt? (20)

Jdk Tools For Performance Diagnostics
Jdk Tools For Performance DiagnosticsJdk Tools For Performance Diagnostics
Jdk Tools For Performance Diagnostics
 
Everything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap DumpsEverything you wanted to know about Stack Traces and Heap Dumps
Everything you wanted to know about Stack Traces and Heap Dumps
 
So You Want To Write Your Own Benchmark
So You Want To Write Your Own BenchmarkSo You Want To Write Your Own Benchmark
So You Want To Write Your Own Benchmark
 
Explore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav MishraExplore the history, versions and features of Java- a report by Pranav Mishra
Explore the history, versions and features of Java- a report by Pranav Mishra
 
Distributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevdayDistributed systems at ok.ru #rigadevday
Distributed systems at ok.ru #rigadevday
 
Concurrency in Java
Concurrency in  JavaConcurrency in  Java
Concurrency in Java
 
JVM
JVMJVM
JVM
 
Java Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky ProblemJava Tools and Techniques for Solving Tricky Problem
Java Tools and Techniques for Solving Tricky Problem
 
Down to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap DumpsDown to Stack Traces, up from Heap Dumps
Down to Stack Traces, up from Heap Dumps
 
Bytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASMBytecode manipulation with Javassist and ASM
Bytecode manipulation with Javassist and ASM
 
Java Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVMJava Runtime: повседневные обязанности JVM
Java Runtime: повседневные обязанности JVM
 
Do we need Unsafe in Java?
Do we need Unsafe in Java?Do we need Unsafe in Java?
Do we need Unsafe in Java?
 
Николай Папирный Тема: "Java memory model для простых смертных"
Николай Папирный Тема: "Java memory model для простых смертных"Николай Папирный Тема: "Java memory model для простых смертных"
Николай Папирный Тема: "Java memory model для простых смертных"
 
Multithreading 101
Multithreading 101Multithreading 101
Multithreading 101
 
JDK not so hidden treasures
JDK not so hidden treasuresJDK not so hidden treasures
JDK not so hidden treasures
 
Core Java Programming Language (JSE) : Chapter XII - Threads
Core Java Programming Language (JSE) : Chapter XII -  ThreadsCore Java Programming Language (JSE) : Chapter XII -  Threads
Core Java Programming Language (JSE) : Chapter XII - Threads
 
Build, logging, and unit test tools
Build, logging, and unit test toolsBuild, logging, and unit test tools
Build, logging, and unit test tools
 
Real World Mocking In Swift
Real World Mocking In SwiftReal World Mocking In Swift
Real World Mocking In Swift
 
Defcon CTF quals
Defcon CTF qualsDefcon CTF quals
Defcon CTF quals
 
How & why-memory-efficient?
How & why-memory-efficient?How & why-memory-efficient?
How & why-memory-efficient?
 

Ähnlich wie Thread dump troubleshooting

Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1app
 
Analysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationAnalysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationTerry Cho
 
Ch10.애플리케이션 서버의 병목_발견_방법
Ch10.애플리케이션 서버의 병목_발견_방법Ch10.애플리케이션 서버의 병목_발견_방법
Ch10.애플리케이션 서버의 병목_발견_방법Minchul Jung
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumpsTier1 App
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfjexp
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dumpejlp12
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slowaragozin
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
 
Lec7!JavaThreads.ppt
Lec7!JavaThreads.pptLec7!JavaThreads.ppt
Lec7!JavaThreads.pptssuserec53e73
 
Lec7!JavaThreads.ppt java multithreading
Lec7!JavaThreads.ppt java multithreadingLec7!JavaThreads.ppt java multithreading
Lec7!JavaThreads.ppt java multithreadingkavitamittal18
 
Jvm performance tuning
Jvm performance tuningJvm performance tuning
Jvm performance tuningIgor Igoroshka
 
Concurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and GotchasConcurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and Gotchasamccullo
 
Threads v3
Threads v3Threads v3
Threads v3Sunil OS
 
Java. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsJava. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsМарія Русин
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java PlatformSivakumar Thyagarajan
 

Ähnlich wie Thread dump troubleshooting (20)

Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Analysis bottleneck in J2EE application
Analysis bottleneck in J2EE applicationAnalysis bottleneck in J2EE application
Analysis bottleneck in J2EE application
 
Ch10.애플리케이션 서버의 병목_발견_방법
Ch10.애플리케이션 서버의 병목_발견_방법Ch10.애플리케이션 서버의 병목_발견_방법
Ch10.애플리케이션 서버의 병목_발견_방법
 
java_threads.ppt
java_threads.pptjava_threads.ppt
java_threads.ppt
 
Don't dump thread dumps
Don't dump thread dumpsDon't dump thread dumps
Don't dump thread dumps
 
Looming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdfLooming Marvelous - Virtual Threads in Java Javaland.pdf
Looming Marvelous - Virtual Threads in Java Javaland.pdf
 
Java troubleshooting thread dump
Java troubleshooting thread dumpJava troubleshooting thread dump
Java troubleshooting thread dump
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
 
Lec7!JavaThreads.ppt
Lec7!JavaThreads.pptLec7!JavaThreads.ppt
Lec7!JavaThreads.ppt
 
Lec7!JavaThreads.ppt java multithreading
Lec7!JavaThreads.ppt java multithreadingLec7!JavaThreads.ppt java multithreading
Lec7!JavaThreads.ppt java multithreading
 
Lec7!JavaThreads.ppt
Lec7!JavaThreads.pptLec7!JavaThreads.ppt
Lec7!JavaThreads.ppt
 
Jvm performance tuning
Jvm performance tuningJvm performance tuning
Jvm performance tuning
 
Java Concurrency
Java ConcurrencyJava Concurrency
Java Concurrency
 
Concurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and GotchasConcurrency in Eclipse: Best Practices and Gotchas
Concurrency in Eclipse: Best Practices and Gotchas
 
Java Thread
Java ThreadJava Thread
Java Thread
 
Threads v3
Threads v3Threads v3
Threads v3
 
Java. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax ApplicationsJava. Explicit and Implicit Wait. Testing Ajax Applications
Java. Explicit and Implicit Wait. Testing Ajax Applications
 
Java On Speed
Java On SpeedJava On Speed
Java On Speed
 
Batch Applications for the Java Platform
Batch Applications for the Java PlatformBatch Applications for the Java Platform
Batch Applications for the Java Platform
 

Thread dump troubleshooting

  • 1. Thread Dump Troubleshooting Jie Chen March 2010
  • 2. ©2010 Oracle Corporation Agenda Why & When to take Thread Dump How to take Thread Dump Thread State Analyzing Case Study
  • 3. ©2010 Oracle Corporation Why & When to take Thread Dump What / Why A snapshot of all threads in Java application Showing each thread’s state / health When Bad performance System hangs CPU High Usage
  • 4. How to take Thread Dump Weblogic Windows: (Note 659452.1) Edit *.cmd to output the dump Press Ctrl+Break Unix/Linux: (Note 659452.1) Edit *.sh Get PID by “ps -ef|grep java” “Kill -3 <PID>” ©2010 Oracle Corporation E.g, startAgile.cmd %JAVA_HOME%inava %JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -Dweblogic.Name=%SERVER_NAME% … weblogic.Server>c:/temp/mydump.log
  • 5. How to take Thread Dump Oracle AS Windows: (Note 437464.1) Get PID (Process ID) by “opmnctl status –l” Run thdump utility by “thdump <PID>” Unix/Linux (Note 361729.1) Get PID by “opmnctl status -l” Run “kill -3 <PID>” Output written to OC4J~home~default-island~1 (default) ©2010 Oracle Corporation
  • 6. Thread State Running Blocked / Waiting for Monitor Entry Waiting / Timed Waiting Sleeping / Waiting on Condition ©2010 Oracle Corporation
  • 7. Thread State Running Blocked / Waiting for Monitor Entry Waiting / Timed Waiting Sleeping / Waiting on Condition ©2010 Oracle Corporation
  • 8. Analyzing Understand Application Take more Dumps in a Short Duration Eliminate Running / Idle Threads Analyze Blocked / Waiting Threads ©2010 Oracle Corporation
  • 9. Case Study 1 CPU High Usage Get Thread Dump first Get TID (Thread ID) Process Explorer (Windows) “ps –eL|grep java” (Unix/Linux) 3. Convert TID to hexadecimal 4. Find out the problem stack ©2010 Oracle Corporation
  • 10. Case Study 2 Classic Deadlock One thread is blocked to acquire resource which is hold by other blocked thread(s) ©2010 Oracle Corporation =================================================== "Thread-1": at zigzag.threaddump.demo.TestDeadLock.run(TestDeadLock.java:27) - waiting to lock <0x22a15c98> (a java.lang.Object) - locked <0x22a15ca0> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "Thread-0": at zigzag.threaddump.demo.TestDeadLock.run(TestDeadLock.java:16) - waiting to lock <0x22a15ca0> (a java.lang.Object) - locked <0x22a15c98> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) Found 1 deadlock. System Hangs
  • 11. Case Study 3 Resource Contention Two or more threads are fighting for the same resource(s) ©2010 Oracle Corporation "Thread-2" prio=6 tid=0x02b48000 nid=0x120c waiting for monitor entry [0x02f1f000] java.lang.Thread.State: BLOCKED (on object monitor) at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:11) - waiting to lock <0x22a15e30> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "Thread-1" prio=6 tid=0x02b46c00 nid=0xc3c waiting for monitor entry [0x02ecf000] java.lang.Thread.State: BLOCKED (on object monitor) at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:11) - waiting to lock <0x22a15e30> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) "Thread-0" prio=6 tid=0x02b45800 nid=0x49c waiting on condition [0x02e7f000] java.lang.Thread.State: TIMED_WAITING (sleeping) at java.lang.Thread.sleep(Native Method) at zigzag.threaddump.demo.ResourceContention.run(ResourceContention.java:12) - locked <0x22a15e30> (a java.lang.Object) at java.lang.Thread.run(Unknown Source) Bad Performance
  • 12. Case Study 4 Out of Threads No more room for additional threads running ©2010 Oracle Corporation E.g. 5 tasks need to run but only 2 threads are allowed concurrently. Task 2,3 and 4 have to wait until Task 0 and 1 finish. "Zigzag_ThreadPool-1" prio=6 tid=0x02b47000 nid=0x133c runnable [0x02ecf000] java.lang.Thread.State: RUNNABLE at zigzag.threaddump.demo.ThreadPoolTest$1.run(ThreadPoolTest.java:44) at zigzag.threaddump.demo.ThreadPool$PooledThread.run(ThreadPoolTest.java:185) "Zigzag_ThreadPool-0" prio=6 tid=0x02b46400 nid=0x11d0 runnable [0x02e7f000] java.lang.Thread.State: RUNNABLE at zigzag.threaddump.demo.ThreadPoolTest$1.run(ThreadPoolTest.java:44) at zigzag.threaddump.demo.ThreadPool$PooledThread.run(ThreadPoolTest.java:185) Bad Performance
  • 13. Case Script CPU High Usage Classic Deadlock Resource Contention Out of Threads ©2010 Oracle Corporation
  • 14. Third Part Utility Process Explorer http://technet.microsoft.com/en-us/sysinternals/bb896653.aspx TDA (Thread Dump Analyzer) https://tda.dev.java.net ©2010 Oracle Corporation