Why doesn't the -baseline option of jhat work?

℡╲_俬逩灬. 提交于 2019-12-10 16:01:34

问题


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.


回答1:


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.




回答2:


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



来源:https://stackoverflow.com/questions/1279346/why-doesnt-the-baseline-option-of-jhat-work

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!