Tools available for debugging production Issues in Java applications

Java Guy picture Java Guy · May 28, 2010 · Viewed 7.5k times · Source

Just wondering what are various tools & techniques out there to debug production issues on Java applications. Like,

  • What are the ways and tools to take thread dumps?
  • What are the ways and tools to take heap dumps?
  • What are the tools to analyse the above dumps?

(Assumption all are in Linux/Unix environment)

Answer

Pascal Thivent picture Pascal Thivent · May 28, 2010

What are the ways and tools to take thread dumps?

For a thread dump, you can use JConsole, VisualVM or, more simply, send a QUIT signal to the target process

kill -QUIT <pid> 

or

kill -3 <pid>

Since Java 5, there is also jstack which is platform independent and has a nice -m option to print both Java and native frames (mixed mode).

What are the ways and tools to take heap dumps?

With Sun VMs, jmap, Sun JConsole, Sun VisualVM, SAP JVMMon. For IBM VMs, check this page. Actually, the Eclipse MAT wiki has a nice Getting a Heap Dump section summarizing all the options.

What are the tools to analyse the above dumps?

For thread dumps I use TDA - Thread Dump Analyzer (for Sun JDKs) and IBM Thread and Monitor Dump Analyzer (for IBM JDKs). Samurai is also very nice (it works like a tail -f and picks up thread dumps from your std/stderr automatically, it can also read "-verbose:gc" logs) and has been tested against VMs from Apple, BEA, HP, Sun and IBM (can also read IBM's javacore).

For heap dumps, I use VisualVM (for Sun JDKs) or IBM Heap Dump Analyzer (only for IBM JDKs) or the über awesome Eclipse MAT depending on my needs. The later is able to work with HPROF binary heap dumps (produced by Sun, HP, SAP, etc... JVMs), IBM system dumps (after preprocessing them), and IBM portable heap dumps (PHD) from a variety of IBM platforms).