What does “retained size” mean in jVisualVM's memory inspector?

允我心安 提交于 2019-11-28 07:06:10

问题


Jvisualvm heap dump on summary tab has functionality to inspect bigest objects by retained size.

What does retained really mean? How size of an object tree is calculated and shown here?
In case I can see here object (10M) and it's member object (5M) how should I calculate heap impact. Does both of them took 10M or 15M of the heap?
Why I can't see none of our facade huge application objects?

Thanks.


回答1:


What does retained really mean?

How big it would be after a full gc. E.g. a WeakHashMap with a large number of entries could be empty after a GC.

How size of an object tree is calculated and shown here?

The JVM determines this using an internal API.

In case I can see here object (10M) and it's member object (5M) how should I calculate heap impact. Does both of them took 10M or 15M of the heap?

The total is 10 MB. If this is your biggest problem, wouldn't worry about it unless you have a machine with only a few 100 MB. (In which case I would upgrade it)

Why I can't see none of our facade huge application objects?

Perhaps they are not as big in memory as you think?? e.g. they may be expensive to load, but that doesn't make them huge.

BTW: VisualVM is a nice free memory profiler but its only useful for finding obvious problems. I would try a commercial profiler like YourKit (which you can get a free eval license for) for comparison.




回答2:


In case I can see here object (10M) and it's member object (5M) how should I calculate heap impact. Does both of them took 10M or 15M of the heap?

I think it actually took 15M of the heap, object retained size 10M means, 10M will be free when this object(10M) is swept. The member object(5M) is still referenced by other object, and still in the heap. Member object's retained size can be larger than object itself.



来源:https://stackoverflow.com/questions/12600744/what-does-retained-size-mean-in-jvisualvms-memory-inspector

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