OutOfMemoryError - how to kill JVM after creating hprof

I want my java to complete when fishing OutOfMemoryError, I use the file -XX:+HeapDumpOnOutOfMemoryErrorfor dump hprof.
I can’t use kill -9 <pid>it because the JVM must be enabled during the file reset hprof, is there any way to stop the JVM after creating the file hprof?

To be clear, I am using the Sun JVM version 6.

+5
source share
1 answer

This page seems to imply that you can combine -XX:+HeapDumpOnOutOfMemoryErrorand-XX:OnOutOfMemoryError="kill -9 %p"

Presumably, a heap dump is created before running the "On ..." command. (It should be easy to put together something to test it.)

+4
source

All Articles