为什么 jhat 的 -baseline 选项不起作用?

发布于 2024-07-30 18:12:27 字数 172 浏览 10 评论 0原文

为什么每个对象似乎都被标记为新对象,而不仅仅是第二个快照中但不在我的基准快照中的对象? 在网上查看,我看到一些建议,我需要使用 hprof 而不是 jmap 来进行内存转储,但 hprof 似乎以完全相同的格式生成转储。

这是JDK 1.6.0_14; 我在 Windows 和 UNIX 上都试过了。

How come every object appears to be marked new, instead of just objects that are in the second snapshot but not in my baseline snapshot? Looking around online, I see some suggestions that I need to use hprof instead of jmap to make my memory dumps, but it appears that hprof generates dumps in exactly the same format.

This is JDK 1.6.0_14; I have tried on both Windows and UNIX.

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

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

发布评论

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

评论(2

病毒体 2024-08-06 18:12:27

jhat -baseline 确实无法与 jmap 生成的转储一起使用。 我不确定,但我相信这是因为 hprof 从一开始就附加到 JVM 并保留自己的对象跟踪,从而允许它在多个转储中生成一致的 ID。 不要引用我的话。 无论哪种方式,就您而言,重要的一点是 jmap 转储不起作用。

然而,一切并没有失去。 去获取 Eclipse 内存分析器。 (如果您不使用 Eclipse,不用担心,您可以将其作为独立的可执行文件获取。)它比 jhat 更快,使用的内存比 jhat 更少并且它可以执行您想要的操作:

  1. Open dump2 (使用文件|打开堆转储)。 不用费心让它为您创建报告。
  2. 打开dump1(同样的方式)。 再次,没有报告。
  3. 在 dump2 的选项卡中,单击“直方图”
  4. 直方图子选项卡中的工具栏右侧是“与另一个堆转储进行比较”。 点击它。
  5. 从对话框中选择 dump1 作为要用作基线的转储。
  6. 很快,您就看到了 dump2 和基线 dump1 之间的差异。

所有这些都可以通过 jmap 转储正常工作。

jhat -baseline indeed won't work with dumps produced by jmap. I'm not certain, but I believe this is because hprof attaches to the JVM right from the start and keeps its own track of objects, allowing it to produce consistent IDs across multiple dumps. Don't quote me on that. Either way, the important point as far as you're concerned is that jmap dumps don't work.

However, all is not lost. Go and get the Eclipse Memory Analyzer. (If you don't use Eclipse, fear not, you can get it as a standalone executable.) It's faster than jhat, uses less memory than jhat and it can do what you want:

  1. Open dump2 (with File|Open Heap Dump). Don't bother having it create a report for you.
  2. Open dump1 (same way). Again, no report.
  3. In the tab for dump2, click "Histogram"
  4. On the right of the toolbar in the Histogram subtab is "Compare to another Heap Dump". Click it.
  5. Select dump1 from your dialog as the dump to use as the baseline.
  6. Presto, you have the differences between dump2 and the baseline dump1.

All of this works fine with a jmap dump.

心如荒岛 2024-08-06 18:12:27

看来你需要使用hprof。 但您确定使用同一个虚拟机实例吗?

-baseline 选项允许比较两个转储(如果它们是由 HPROF 生成且来自同一 VM 实例)。 如果相同的对象出现在两个转储中,它将被排除在报告的新对象列表之外。 将第一个转储指定为基线,分析可以重点关注自获得基线以来第二个转储中创建的对象。

如果一切都被认为是新的,我将确保这是同一虚拟机实例。

此处

It seems that you need to use hprof. But are you sure you use the same VM instance ?

The -baseline option allows two dumps to be compared if they were produced by HPROF and from the same VM instance. If the same object appears in both dumps it will be excluded from the list of new objects reported. One dump is specified as a baseline and the analysis can focus on the objects that are created in the second dump since the baseline was obtained.

If everything is considered as new, I will make sure that's the same instance of the VM.

Here

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