Generate Java Heap Dump on uncaught Exception

前端 未结 3 2013
没有蜡笔的小新
没有蜡笔的小新 2020-12-09 23:18

I try to generate a Heap Dump when a uncaught exception is fired. I tried using jmap, but because the process is finished when the exception happens this is not possible.

3条回答
  •  北海茫月
    2020-12-09 23:48

    Try to put your processing into a deamon thread. this way you can access it with memory analysis tools. JVisualVM is a JDK tool you can find it in your JAVA_HOME\bin.

    There are also another way, called dump analyser. You run your application with these JVM parameters :

    • -XX:+HeapDumpOnOutOfMemoryError

    • -XX:HeapDumpPath="your_path"

    But this is used only if you have an OutOfMemoryError. Try to find if it's possible to generate the dump for any performance.

    Another good eclipse based tool is MemoryAnalyzer

提交回复
热议问题