Pages

Monday, November 17, 2014

Eclipse Memory Analyzer: Shallow heap and Retained heap

Developers are more concerned about the size of objects when they are created. Eclipse memory analyzer gives us information about the size of the object in 2 calculations.

Shallow Heap
Retained Heap

Shallow heap is the memory consumed by one object. An object needs 32 or 64 bits (depending on the OS architecture) per reference, 4 bytes per Integer, 8 bytes per Long, etc. Depending on the heap dump format the size may be adjusted (e.g. aligned to 8, etc...) to model better the real consumption of the VM.

Shallow size of an object is the amount of allocated memory to store the object itself, not taking into account the referenced objects

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

Dead objects are shown only with shallow size, as they do not actually retain any other objects.

Generally speaking, shallow size of an object is its "flat" size in the heap whereas the retained size of the same object is the amount of heap memory that will be freed when the object is garbage collected.

For example the shallow size of an instance of java.lang.String will not include the memory needed for the underlying char[] where as retained size includes.

4 comments :

  1. Excellent site. A lot of useful information here. I'm sending it to some pals ans also sharing
    in delicious. And naturally, thank you for your sweat!

    Feel free to surf to my webpage brainfire pills

    ReplyDelete
  2. It's very easy to find out any topic on net as compared to books,
    as I found this article at this website.

    Feel free to surf to my web-site - CogniQ Brain Supplement

    ReplyDelete
  3. Its like you read my mind! You appear to know a lot about this, like you wrote
    the book in it or something. I think that you can do with some pics to drive the message home a bit, but instead of that, this is fantastic blog.
    A fantastic read. I will definitely be back.

    Also visit my blog; Brain Peak

    ReplyDelete
  4. It is the best time to make some plans for the future and it's time to be happy.
    I have read this post and if I could I desire
    to suggest you some interesting things or suggestions.
    Perhaps you can write next articles referring to this article.
    I wish to read more things about it!

    ReplyDelete