0

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.
user2178964
  • 124
  • 6
  • 16
  • 40

1 Answers1

0

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'"
Thorbjørn Ravn Andersen
  • 73,784
  • 33
  • 194
  • 347