Java:比较 Netbeans 中的内存堆转储

发布于 2024-08-13 06:06:50 字数 1177 浏览 4 评论 0原文

如何比较 Netbeans 中的内存堆转储?

我所做的是将我的项目配置为使用分析,然后在选定的代码行添加几个分析点(类似于设置断点)。这些分析点会触发“快照”,从而创建内存转储。

当我的应用程序运行时,分析选项卡会列出每个分析点,并标记它所遇到的点击次数,并提供一个链接来打开该分析点的报告。此外,探查器控制面板会将新快照添加到列表中。

如果我打开这些报告并点击链接,或者从控制面板打开快照,在这两种情况下,Netbeans 都会打开一个包含 SummaryClasses< 的 snapshot 选项卡/code>、InstancesOQL 子屏幕。

如果我从 Profiler 控制面板中选择其中之一,然后按“保存”,该文件将以 HPROF 格式保存。

如果我选择菜单 Profile -->;比较内存快照,它只允许我选择NPS格式的文件,我无法获取任何格式的文件。

我相信“比较内存快照”听起来应该能够比较堆转储,但我不知道该怎么做。

问题

  • Netbeans 将 NPS 文件放在哪里(如果它确实创建了它们)?如果不是,我如何让 Netbeans 创建从分析点触发的 NPS 文件?

  • 有没有办法让 Netbeans 比较 HPROF 文件,因为那毕竟是内存堆转储?

  • 或者我只是完全忽略了某些事情?

谢谢!


背景

使用 Netbeans 6.7.1

我正在对一个非常大的内存进行分析存在内存泄漏问题的复杂应用程序。我成功地使用 Netbeans 的分析器和网络分析器的组合解决了大部分泄漏问题。 JHAT(JDK自带的命令行util)。我需要更强大的堆分析功能来处理剩下的落后者 - 以前有效的假设优先方法正在变得越来越有效。

这个问题非常具体,有关更多背景信息,请参阅我之前问过的一个问题

How do I compare memory heap dumps in Netbeans?

What I have done is to configure my project to use profiling, then added several profiling points at chosen lines of code (similar to setting breakpoints). These profiling points trigger a "snapshot", which creates a memory dump.

As my application is running, the profiling tab lists each of the profiling points, and marks the number of hits it has encounteed, providing a link to open a report for that profiling point. In addition, the profiler control panel adds the new snapshots to a list.

If I open these reports and follow the links, or open the snapshots from the control panel, in both cases, Netbeans opens a snapshot tab with Summary, Classes, Instances and OQL subscreens.

If I select one of them from the Profiler control panel, and press save, the file gets saved in HPROF format.

If I select the menu Profile --> Compare Memory Snapshots, it only allows me to select NPS format files, of which I cannot obtain any.

I believe Compare Memory Snapshots sounds like it should be able to compare heap dumps, but I cannot figure out how to do it.

Questions

  • Where is Netbeans putting the NPS files (if it is indeed creating them)? If not how do I get Netbeans to create NPS files triggered from profiling points?

  • Is there a way to get Netbeans to compare HPROF files, since that is the memory heap dump after all?

  • Or am I simply completely overlooking something altogether?

Thanks!


Background

Using Netbeans 6.7.1.

I am doing memory profiling for a really large & complex application that has a memory leak problem. I have managed to solve large chunks of the leaks using a combination of Netbeans' profiler & JHAT (command line util that comes with JDK). It's the remaining stragglers that I need a more powerful heap analysis capabilities for - the
hypothesis-first approach that worked previously is becoming decreasingly effective.

This question's really specific, for more background see a question I have asked previously.

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

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

发布评论

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

评论(2

神妖 2024-08-20 06:06:50

不幸的是,我并没有要求推荐其他可以做到这一点的工具。

此后我发现 Netbeans 确实支持内存堆转储的比较,但只是间接支持。编辑分析点,以便在“堆”上选择“快照”。这意味着 Netbeans 将生成 .nps 文件而不是 .hprof 文件。

.nps 文件是 Netbean 自己的专有文件格式,而 .hprof 是“通用”堆转储格式,几乎所有分析工具都可以理解,包括 JHAT、MAT 和 Java。网豆。

但是,Netbeans 的限制是它可以查看 .hprof 文件并分析它们,但无法将它们与另一个 .hprof 文件进行比较。不过,它可以将一个 .nps 文件与另一个 .nps 文件进行比较。然而,可用的分析级别受到 .nps 文件的限制,因此这是一个权衡。


因此,回答我自己的问题:

Netbeans 将 NPS 文件放在哪里(如果它确实正在创建它们)?如果不是,我如何让 Netbeans 创建从分析点触发的 NPS 文件?

  • 两者择一,每个分析点只能选择一个。

有没有办法让 Netbeans 比较 HPROF 文件,因为那毕竟是内存堆转储?

  • 不。您无法与 HPROF 进行比较。比较两个不同时间点的内存的唯一方法似乎是比较两个 NPS。

Unfortunately, I was not asking for recommendations on other tools which can do this.

I have since found that Netbeans does indeed support comparison of memory heap dumps, but only indirectly. Edit the profiling points such that the "Snapshot" is selected over "heap". This means that Netbeans will produce a .nps file instead of a .hprof file.

The .nps file is Netbean's own proprietary file format, whereas .hprof is the "universal" heap dump format, understood by almost all profiling tools, including JHAT, MAT & Netbeans.

However, the limitation with Netbeans is that it can look at .hprof files, and analyse them, but it cannot compare them to another .hprof file. It can, though, compare one .nps file to another .nps file. However the level of analysis available is limited with .nps files, so that's the trade-off.


So, to answer my own questions:

Where is Netbeans putting the NPS files (if it is indeed creating them)? If not how do I get Netbeans to create NPS files triggered from profiling points?

  • It is one or the other, you can only choose one per profiling point.

Is there a way to get Netbeans to compare HPROF files, since that is the memory heap dump after all?

  • No. You cannot compare to HPROF's. The only way to compare the memory at two different points in time appears to be to compare two NPS'es.
甜警司 2024-08-20 06:06:50

我建议使用 eclipse 的内存分析器: http://www.eclipse.org/mat/

我知道您是 netbeans 用户,但 mat 实际上是一个独立的应用程序(基于 rcp)并且能够加载和比较 hprof 文件。

我发现它是最好的堆分析器,特别是对于较大的堆转储。

I would suggest using eclipse's memory analyzer: http://www.eclipse.org/mat/

I know that you are a netbeans user but mat is actually a standalone application (rcp based) and is capable of loading and comparing hprof files.

I found that it was the best heap analyzer around, particularly with larger heap dumps.

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