问题描述
为什么每个对象看起来都被标记为新对象,而不只是第二个快照中的对象,而不是我的基准快照中的对象?在线浏览时,我看到一些建议,我需要使用hprof而不是jmap来进行内存转储,但是看来hprof会以完全相同的格式生成转储.
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.
这是JDK 1.6.0_14;我在Windows和UNIX上都尝试过.
This is JDK 1.6.0_14; I have tried on both Windows and UNIX.
推荐答案
jhat -baseline
确实不适用于 jmap
生成的转储.我不确定,但是我相信这是因为hprof从一开始就附加到JVM并保持自己的对象跟踪,从而允许它在多个转储中生成一致的ID.不要在那上面引用我.无论哪种方式,就您而言,重要的一点是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.
但是,一切并没有丢失.转到并获取 Eclipse内存分析器.(如果您不使用Eclipse,请不要担心,您可以将其作为独立的可执行文件来获得.)它比jhat更快,比jhat 使用更少的内存,并且可以完成您想要的操作:
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:
- 打开dump2(带有文件" |打开堆转储").不用麻烦它为您创建报告.
- 以相同的方式打开dump1.再次,没有报告.
- 在dump2的标签中,点击直方图"
- 直方图"子选项卡中工具栏的右侧是比较另一个堆转储".单击它.
- 从对话框中选择dump1作为转储,以用作基准.
- Presto,您拥有dump2和基线dump1之间的区别.
所有这些都可以通过jmap转储正常工作.
All of this works fine with a jmap dump.
这篇关于为什么jhat的-baseline选项不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!