Java VisualVM Enable Heap Dump on OOME

2020-02-24 01:30发布

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

2条回答
Luminary・发光体
2楼-- · 2020-02-24 02:16

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:

查看更多
我想做一个坏孩纸
3楼-- · 2020-02-24 02:17

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.

查看更多
登录 后发表回答