Friday, October 03, 2014

Obtain a thread dump and heap dump for Java process

Thread dump shows locks used by different threads.
Ways to obtain a thread dump
1. get pid using ps or jps
    jstack pid xyz.log --> thread dump
    jstack -l to print additional information about locks
2. kill -QUIT pid --> thread dump
    kill -3 2>&1
3. login to jconsole  and request a thread dump
4. jrcmd print_threads
5. Login to AdminConsole—>Server —> Monitoring —> Threads - See more at: http://middlewaremagic.com/weblogic/?p=823#sthash.5X2b9Ntr.dpuf

Heap Dump
1. jmap -dump:file=xyz.log PID
Use JMAP to dump heap and analyze using visualVM
2. JConsole to get HeapDump
3. use $JAVA_HOME/bin/jvisualvm to take a heap dump and analyze it. For remote systems, use vnc viewer or xserver to redirect console windows to local env

No comments: