Sunday, August 2, 2015

Java Thead and Heap Dumps

Use jvisualvm if possible.  You can connect remotely.

Manual thread dump (stack traces of all threads):
kill -3 <pid>
The dump is added to the standard out (e.g. the application log).

Manual heap dump (memory jvm is using):
jmap -dump:format=b, file=heapdump.bin <pid>
Run as the user who owns the process (if you can't, try adding the -F flag).
To analyse the heap dump, use Eclipse Memory Analyzer.