开发者

Is there a way to do a live heap dump with ibm-jdk for linux?

开发者 https://www.devze.com 2023-01-29 15:31 出处:网络
I know that it\'s possible to dump heap when an OutOfMemoryException is occuring on t开发者_开发百科his JVM but is it possible to ask a live dump with tools like jmap or jconsole?You need to be aware

I know that it's possible to dump heap when an OutOfMemoryException is occuring on t开发者_开发百科his JVM but is it possible to ask a live dump with tools like jmap or jconsole?


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:

  • HotSpot Diagnostic MBean
  • Required settings to Generate Heapdumps
  • Using the -Xdump Option

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.


I think there is one tool like JProfiler . it 'll nicely work with Eclipse

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号