Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 455
Mike Avatar asked Sep 26 '12 11:09

Mike


People also ask

What is retained size?

Retained size of an object is its shallow size plus the shallow sizes of the objects that are accessible, directly or indirectly, only from this object. In other words, the retained size represents the amount of memory that will be freed by the garbage collector when this object is collected.

What is shallow size and retained size?

shallow size: the size of the object itself. retained size: the size of the object itself, plus the size of other objects that are kept alive by this object.

What is retained in heap dump?

Retained set of X is the set of objects which would be removed by GC when X is garbage collected. Retained heap of X is the sum of shallow sizes of all objects in the retained set of X, i.e. memory kept alive by X.

How does VisualVM analyze heap dump?

Opening a Heap Dump File If you have a heap dump file saved on your local system, you can open the file in Java VisualVM by choosing File > Load from the main menu. Java VisualVM can open heap dumps saved in the . hprof file format. When you open a saved heap dump, the heap dump opens as a tab in the main window.


1 Answers

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.

like image 104
Peter Lawrey Avatar answered Oct 19 '22 19:10

Peter Lawrey