如何在不先进行垃圾收集的情况下在 Java 5 上进行堆转储? [英] How can I take a heap dump on Java 5 without garbage collecting first?

查看:19
本文介绍了如何在不先进行垃圾收集的情况下在 Java 5 上进行堆转储?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个运行 Java 5 的长期运行的服务器应用程序,对其进行分析我们可以看到老一代随着时间的推移缓慢增长.它在完整的 GC 上被正确释放,但我希望能够使用堆转储查看 Eclipse MAT 中无法访问的对象.我已经使用 +XX:HeapDumpOnCtrlBreak 成功获得了堆转储,但是 JVM 总是在转储堆之前进行 GC.显然这不会发生在 Java 6 上,但我们现在停留在 5 上.有什么办法可以预防吗?

We have a long running server application running Java 5, and profiling it we can see the old generation growing slowly over time. It's correctly freed on a full GC, but I'd like to be able to look at the unreachable objects in Eclipse MAT using a heap dump. I've successfully obtained a heap dump using +XX:HeapDumpOnCtrlBreak, but the JVM always does a GC before dumping the heap. Apparently this doesn't happen on Java 6 but we're stuck on 5 for now. Is there any way to prevent this?

推荐答案

我建议使用 3rd-party profiler,例如 YourKit,它可以让您在不先启动 GC 的情况下拍摄快照.额外的好处是,您可以在没有整个 ctrl-break 恶作剧的情况下拍摄快照.

I suggest a 3rd-party profiler such as YourKit, which may allow you to take snapshots without kicking off the GC first. Added bonus, you can take a snapshot without the whole ctrl-break shenanigans.

这篇关于如何在不先进行垃圾收集的情况下在 Java 5 上进行堆转储?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆