java heapdump 大小与 hprof 大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11666667/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
heapdump size vs hprof size
提问by Michael
I recently made a heapdump in a hprof format when my jboss server was running with a xms of 4096m and xmx of 4096m and a permsize of 512m.
最近,当我的 jboss 服务器以 4096m 的 xms 和 4096m 的 xmx 以及 512m 的 permsize 运行时,我制作了一个 hprof 格式的堆转储。
The hprof file generated is over 5gb. When I load the heapdump in visualvm, mat analyzer or yourkit, I only see a total bytes of approximately 1gb. I've tried changed the reachability scope in yourkit but it does not show more than 1 gb.
生成的 hprof 文件超过 5GB。当我在 visualvm、mat 分析器或 yourkit 中加载 heapdump 时,我只看到大约 1gb 的总字节数。我曾尝试更改您的工具包中的可达范围,但它显示的容量不超过 1 GB。
Any idea what this big difference in filesize vs displayed heapdump size can cause?
知道文件大小与显示的堆转储大小的巨大差异会导致什么吗?
ps: I'm using jdk1.6.0_23
ps:我用的是jdk1.6.0_23
Unfortunately I'm not allowed to submit screenshots here.
不幸的是,我不允许在这里提交屏幕截图。
On the filesystem the hprof size is of 5.227.659 kb and in yourkit it states:
在文件系统上,hprof 大小为 5.227.659 kb,在您的套件中它指出:
Objects: 9.738.282 / shallow size 740 mb / retained size: 740 mb String reachable among them: 6.652.515 (68%) / shallow size: 381 mb (51%) / retained size: 381 MB (51%)
对象:9.738.282 / 浅层大小 740 mb / 保留大小:740 mb 其中可到达的字符串:6.652.515 (68%) / 浅层大小:381 mb (51%) / 保留大小:381 MB (51%)
The largest retained size is a byte[] of 206.810.176
最大保留大小是 206.810.176 的字节[]
回答by Andrey Borisov
which command did you use to generate heap dump?
您使用哪个命令生成堆转储?
$JAVA_HOME/bin/jmap -dump:live,format=b,file=c:/tmp/heap_dump.bin PID
maybe you need to pass live option, according to spec
根据规范,您可能需要传递实时选项
-dump:<dump-options> to dump java heap in hprof binary format
dump-options:
live dump only live objects; if not specified,
all objects in the heap are dumped.
回答by haridsv
Did you try "Unreachable Objects Histogram" (you can find the link from the top of "Overview" page)? In one of my heapdumps sized 1509MB, mat shows only 454MB, but the rest is essentially garbage, and sure enough, the sum of "Shallow Heap" in unreachable objects histogram is 966MB.
您是否尝试过“无法访问的对象直方图”(您可以从“概览”页面的顶部找到链接)?在我的一个大小为 1509MB 的堆转储中,mat 仅显示 454MB,但其余的基本上是垃圾,果然,无法访问的对象直方图中的“浅堆”总和是 966MB。
回答by sfali16
This just means that most likely your heap-dump consisted of a large amount of unreachable objects that would have been garbage collected, if a GC were to run. Now that does not mean that you don't still have a leak, it just means that in your 5 GB Hprof, 4 GB of objects were unreachable and hence were not interesting sources of a leak.
这只是意味着您的堆转储很可能包含大量无法访问的对象,如果要运行 GC,这些对象将被垃圾收集。现在这并不意味着您仍然没有泄漏,它只是意味着在您的 5 GB Hprof 中,4 GB 的对象无法访问,因此不是有趣的泄漏源。
In Java a memory leak can only occur if Garbage Collection can't clean out an object because something is holding a reference to it (unexpectedly). So your leak (if any) is to be found in the 1 GB of objects that remained in your hprof.
在 Java 中,只有当垃圾收集无法清除对象时才会发生内存泄漏,因为某些东西持有对它的引用(意外)。因此,您的泄漏(如果有)将在 hprof 中剩余的 1 GB 对象中找到。