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

12,481

Solution 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.

Solution 2

I think the best definition for "Retained" in the VisualVM is the amount of memory that will remain after garbage collection.

In some cases it can be bigger than the "Size" since it reference other objects (or collections) directly or indirectly.

Share:
12,481
Mike
Author by

Mike

Updated on June 03, 2022

Comments

  • Mike
    Mike about 2 years

    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.

  • Mike
    Mike over 11 years
    facade object contains links to big chache objects. In jvisuavm I can see cache object at the top, but can't see facade object that should be at least same size.
  • Vishy
    Vishy over 11 years
    I your situation, I would try a commercial profiler to see if it gives you a different view. Different profilers work differently so running more than one can be helpful if you are not confident one is giving you the right results.