Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there something like "-XX:OnError" or "-XX:OnOutOfMemoryError" in IBM JVM?

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?

like image 681
Volodymyr Bezuglyy Avatar asked Feb 27 '23 11:02

Volodymyr Bezuglyy


1 Answers

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.

like image 166
Vineet Reynolds Avatar answered Mar 02 '23 00:03

Vineet Reynolds