JVM Threaddump OnOutOfMemoryError Unrecognized option

661 Views Asked by At

I want to collect a thread dump when an OutOfMemory error occurs.

I add this option on my run.conf script :

JAVA_OPTS="${JAVA_OPTS} -XX:OnOutOfMemoryError=/bin/kill -3 %p"

But at startup I have :

Unrecognized option: -3
Could not create the Java virtual machine.

I tried with :

JAVA_OPTS="${JAVA_OPTS} -XX:OnOutOfMemoryError=\"/bin/kill -3 %p\""

The result in process launched args is ok :

.... -XX:OnOutOfMemoryError="/bin/kill -3 %p"  ....

But the error at startup is the same :

Unrecognized option: -3
Could not create the Java virtual machine.
1

There are 1 best solutions below

0
On

This is a quoting problem. The /bin/kill -3 %p is not sent down as a single string to the JVM by the shell.

I would suggest trying single quotes instead (untested):

JAVA_OPTS="${JAVA_OPTS} -XX:OnOutOfMemoryError='/bin/kill -3 %p'"