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

The following options are available in the Java HotSpot virtual machine settings:

-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, such features are not available in the IBM JVM.
Is it correct?

I need to call some shell script in case heap heap has been created.
What is the easiest way to do this?

+4
source share
3 answers

The IBM J9 JDK offers the specified ability via the Xdump flag ; This is the preferred way to register dump agents.

A typical way to configure the JVM to dump heaps on OOME is to catch all Out Of Memory errors caused by the application or JVM and prepare a dump for the walk (using the heap inspector).

 -Xdump:system+heap+java:events=systhrow+user,filter=java/lang/OutOfMemoryError,request=exclusive+prepwalk+compact 

Link: Eclipse Memory Analysis Guide

You can also use the JAVA_DUMP_OPTS environment variable . See the IBM JDK Diagnostic Guide for more information on this.

EDIT

To run a command in OOME, the tool parameter must be specified in the -Xdump option.

+5
source

- Xdump is your friend and very powerful.

For your case with OOM, something like:

"- Xdump: Tool: events = cast, filter = * OutOfMemoryError, process = cmd_to_run

+3
source

I expected the IBM JVM to support the same flags as the instrumental version of the Sun JVM, if I remember correctly. Is it possible to compare command line options between major versions of Java? (Ie Sun 1.6 vs IBM 1.4.2?)

If you don’t find a solution for flags, you can take advantage of the fact that the IBM JVM updates the /tmp/dump-locations file by adding the full path to the dump file. The cron task can run your script when this file is affected since it was last run.

0
source

All Articles