thread dumps on fatal JVM error without intervention
954317Mar 6 2013 — edited Mar 14 2013Hi All,
I tried testing out the optional commands that are allowed on the JVM options to create thread dumps on fatal JVM error. Below are 2 cases to create a thread dump using kill -3 command 1) is when an OOM error occurs and 2) when any fatal error occurs and JVM goes down.
As you see from the output below, on OOM error the kill -3 command is working from “executing kill -3 9644’ where, %p is replaced by process id 9644. The same is not true for the case for OnErrror, my assumption was the OnError is triggered for all errors including OOM error. I am going to post the same to JVM news groups and check if, I can get help from there.
This is closest I have found to trigger a thread dump on fatal JVM error without intervention.
Thanks
1)
d:\Development\examples>java -D64 -XX:OnOutOfMemoryError="kill -3 %p " -Xmx10m -Xloggc:gc.log OOM
#
# java.lang.OutOfMemoryError: Java heap space
# -XX:OnOutOfMemoryError="kill -3 %p "
# Executing "kill -3 9644 "...
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at OOM.main(OOM.java:6)
2)
d:\Development\examples>java -D64 -XX:OnError="kill -3 %p " -Xmx10m -Xloggc:gc.log OOM
Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
at OOM.main(OOM.java:6)