简体   繁体   English

Java堆转储(hprof文件)比驻留内存小得多

[英]Java heap dump (hprof file) is much smaller that resident memory

When running top is see my RES is 4.7GB, which is fine, since I set -Xmx8g , but when I dump it to hprof file, I get about half a gig file. 当运行top时看到我的RES是4.7GB,这很好,因为我设置-Xmx8g ,但是当我将它转储到hprof文件时,我得到大约半个gig文件。

Isn't is suppose to contain all memory ? 不是假设包含所有内存吗? By the way, even if I force GC (using jcmd) I still see 4.7G resident. 顺便说一句,即使我强制GC(使用jcmd)我仍然看到4.7G常驻。

Heap dump file (hprof) is not a memory dump, but object heap dump. 堆转储文件(hprof)不是内存转储,而是对象堆转储。 It contains only java objects. 它只包含java对象。

Heap dump file does not include - non-heap arreas of memory (eg code cache, metaspace, etc) - some heap objects (eg classes) are not included in dump - free regions reserved but not used in heap 堆转储文件不包括 - 内存的非堆区域(例如代码缓存,元空间等) - 某些堆对象(例如类)不包含在保留但未在堆中使用的无转储区域中

In your case, you probably have a lot of unused heap space. 在您的情况下,您可能有很多未使用的堆空间。 GC does not return used space to OS, so RES size remain 4.7G GC不会将已用空间返回到OS,因此RES大小保持为4.7G

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM