7

According to documentation one could automatically take a heap dump when the application encounters an OutOfMemoryException.
After OutOfMemoryException process just disappear from left menu.
How does this feature works in VisualVM?

Thanks.


C:\work\temp>java -XX:HeapDumpPath=c:/work/temp/file.hprof -XX:+HeapDumpOnOutOfMemoryError -jar example.jar

Mike
  • 17,033
  • 22
  • 85
  • 113

2 Answers2

21

As far as I know, that option in JVisualVM is equivalent to specifying -XX:+HeapDumpOnOutOfMemoryError as a JVM parameter. This causes the JVM to create a heap dump file when it encounters an OutOfMemoryError. This file can be then loaded into JVisualVM (or into a profiler) and analyzed there. The directory where the file is stored is defined by the -XX:HeapDumpPath parameter.

See also:

Community
  • 1
  • 1
Eli Acherkan
  • 6,251
  • 2
  • 26
  • 34
3

Seems application just exited upon OOM. In this case, you must run your app with special -XX params. See "dump" params in JVM documentation. After application dies, you can examine dump in your tool.

Victor Sorokin
  • 11,395
  • 1
  • 32
  • 48
  • Using same method I can dump heap to file when java.lang.OutOfMemoryError is thrown. Just wonder what is "visual tool" is all about?.. – Mike Nov 29 '11 at 13:24
  • I guess VisualVM just can't cope with application which going to exit. – Victor Sorokin Nov 29 '11 at 13:26
  • Low tool quality as for me. I would expect it logically to show snapshot in same place regardless process liveness. – Mike Nov 29 '11 at 13:48
  • 3
    And bug in the documentation. Provided `-XX:-HeapDumpOnOutOfMemoryError` but works only with `-XX:+HeapDumpOnOutOfMemoryError` – Mike Nov 29 '11 at 15:33
  • I found it very unuseful to remove app node from list of processes on process exit too. After OOM happend you can analyze heap dump file with Eclipse Memory Analyzer Tool. – Askar Kalykov Jan 10 '13 at 08:42