I know that it's possible to dump heap when an OutOfMemoryException
is occuring on this JVM but is it possible to ask a live dump with tools like jmap
or jconsole
?
Start the administrative console. In the navigation pane, click Troubleshooting > Java dumps and cores. Select the server_name for which you want to generate the heap dump. Click Heap dump to generate the heap dump for your specified server.
The -XX:+HeapDumpOnOutOfMemoryError command-line option tells the HotSpot VM to generate a heap dump when an allocation from the Java heap or the permanent generation cannot be satisfied.
A heap dump is a snapshot of all the objects in the Java Virtual Machine (JVM) heap at a certain point in time. The JVM software allocates memory for objects from the heap for all class instances and arrays.
You need to be aware that there are "system" dumps (basically OS core files) and "heap" aka portable heap dumps (PHD). The later ones are less usefull as they do not contain actual data. They are hower enabled by default.
On AIX or Linux Typically you will set up -Xdump:system
(short for -Xdump:system:events=gpf+user
) to allow kill -3 <pid>
to trigger a heap dump.
BTW, you can with the default options use kill -ABRT <pid>
. However this will terminate your JVM.
Run java -Xdump:what
to see your defaults, like:
> /usr/java6/bin/java -Xdump:what -version
Registered dump agents
----------------------
-Xdump:system:
events=gpf+abort+traceassert,
label=/home/u0002824/core.%Y%m%d.%H%M%S.%pid.%seq.dmp,
range=1..0,
priority=999,
request=serial
----------------------
...
java version "1.6.0"
Java(TM) SE Runtime Environment (build pap3260sr9fp2-20110627_03(SR9 FP2))
With turned on system dumps:
> /usr/java6/bin/java -Xdump:system -Xdump:what -version
Registered dump agents
----------------------
-Xdump:system:
events=gpf+user+abort+traceassert,
label=/home/u0002824/core.%Y%m%d.%H%M%S.%pid.%seq.dmp,
range=1..0,
priority=999,
request=serial
----------------------
-Xdump:heap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/home/u0002824/heapdump.%Y%m%d.%H%M%S.%pid.%seq.phd,
range=1..4,
priority=500,
request=exclusive+compact+prepwalk,
opts=PHD
----------------------
-Xdump:java:
events=gpf+user+abort+traceassert,
label=/home/u0002824/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..0,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:java:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/home/u0002824/javacore.%Y%m%d.%H%M%S.%pid.%seq.txt,
range=1..4,
priority=400,
request=exclusive+preempt
----------------------
-Xdump:snap:
events=gpf+abort+traceassert,
label=/home/u0002824/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..0,
priority=300,
request=serial
----------------------
-Xdump:snap:
events=systhrow,
filter=java/lang/OutOfMemoryError,
label=/home/u0002824/Snap.%Y%m%d.%H%M%S.%pid.%seq.trc,
range=1..4,
priority=300,
request=serial
----------------------
...
Do not forget to run jre/bin/jextract
on the core. * .dmp files.
You have a few options:
This list isn't exhaustive.
OK, I'll finally answer to myself : the application has a remote admin interface, so I will implement a new command that is calling the com.ibm.jvm.Dump.HeapDump()
method.
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