I have Java program running in Linux platform and it crash quite often;at this situation, I would like to have heapdump automatically.
Does anyone have script/method to create a Heap Dump Automatically when Java process Hits "OutOfMemory Error" on Linux?
I would appreciate your help.
To take a heap dump automatically, edit {installation directory}/bin/setenv.sh and add this to the JAVA_OPTS:
-XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=[path to heap dump]
Have a look at this page for JVM options, specifically:
-XX:HeapDumpPath=./java_pid.hprof Path to directory or filename for heap dump. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
-XX:-HeapDumpOnOutOfMemoryError Dump heap to file when java.lang.OutOfMemoryError is thrown. Manageable. (Introduced in 1.4.2 update 12, 5.0 update 7.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With