有没有办法使用 ibm-jdk for linux 进行实时堆转储?

发布于 2024-10-06 19:36:01 字数 114 浏览 6 评论 0原文

我知道当 JVM 上发生 OutOfMemoryException 时可以转储堆,但是否可以使用 jmapjconsole 等工具请求实时转储代码>?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

寂寞美少年 2024-10-13 19:36:01

您需要注意,存在“系统”转储(基本上是操作系统核心文件)和“堆”,又名便携式堆转储(PHD)。后面的内容不太有用,因为它们不包含实际数据。然而它们默认是启用的。

在 AIX 或 Linux 上 通常,您将设置 -Xdump:system-Xdump:system:events=gpf+user 的缩写)以允许 kill -3 < ;pid> 触发堆转储。

顺便说一句,您可以使用默认选项 kill -ABRT。然而,这将终止您的 JVM。

运行 java -Xdump:what 来查看默认设置,例如:

> /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))

打开系统转储时:

> /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
----------------------
...

不要忘记在核心上运行 jre/bin/jextract。 * .dmp 文件。

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.

时光无声 2024-10-13 19:36:01

好的,我最终会回答自己:应用程序有一个远程管理界面,因此我将实现一个调用 com.ibm.jvm.Dump.HeapDump() 方法的新命令。

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.

抚你发端 2024-10-13 19:36:01

我认为有一种工具像 JProfiler 。它可以很好地与 Eclipse 配合使用

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文