2012-12-13

How to get a heap dump

..out of running JVM

JDK 5:

~/sw/java/jdk/jdk1.5.0_17/bin/jmap -heap:format=b 765

JDK 6:

~/sw/java/jdk/jdk1.6.0_19/bin/jmap -dump:file=JON-OOME.hprof 765

…automatically when OutOfMemoryEx­ception strikes

Dump heap to file when java.lang.OutOf­MemoryError is thrown:

java ... -XX:-HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=<path>

-XX:HeapDumpPaths default is ./java_pid<pid>.hprof

Sources


0