There are two following options in Java HotSpot VM Options:
-XX:OnError="<cmd args>;<cmd args>" Run user-defined commands on fatal error. (Introduced in 1.4.2 update 9.)
-XX:OnOutOfMemoryError="<cmd args>;
<cmd args>" Run user-defined commands when an OutOfMemoryError is first thrown. (Introduced in 1.4.2 update 12, 6)
As far as I can see there are no such options in IBM JVM.
Is it correct?
I need to call some shell script in case if heap dump was generated.
What is the simplest way to do it?
The IBM J9 JDK offers the said ability via the -Xdump flag; this is the preferred way of registering dump agents.
A typical way of configuring the JVM to produce heap dumps on OOME is to catch all Out Of Memory Errors thrown by the application or by the JVM, and to prepare the dump for "walking" (with a heap inspector).
-Xdump:system+heap+java:events=systhrow+user,filter=java/lang/OutOfMemoryError,request=exclusive+prepwalk+compact
Ref:Eclipse Memory Analyzer Guide
The JAVA_DUMP_OPTS environment variable can also be used. More information on this is available in the IBM JDK diagnostics guide.
EDIT
For the purpose of running a command on a OOME, the tool option needs to be specified in the -Xdump option.
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