I want my java to exit when catching OutOfMemoryError
, I'm using the -XX:+HeapDumpOnOutOfMemoryError
to dump hprof
file.
I can't use kill -9 <pid>
because the JVM needs to be up while dumping the hprof
file, is there any way to stop the JVM after the hprof
file created?
To be clear I'm using Sun's JVM version 6.
This page seems to imply that you can combine -XX:+HeapDumpOnOutOfMemoryError
and -XX:OnOutOfMemoryError="kill -9 %p"
Presumably, the heap dump is created before the "On..." command is run. (It should be easy to throw together something to test this out.)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.