Shallow, Retained and Deep Size
Shallow size – size of the object itself including only references to other objects, without objects which are referenced.
Retained size – size of the object including references to other objects and objects which are referenced, but are not shared with any other objects. In other words, the retained memory of an object is the amount of memory that would be freed if the object A was eligible to be collected by GC. Memory of the object E couldn’t be freed, because it is also an instance variable of the object B.
Deep size – size of the object including references to other objects and objects which are referenced, even if they are shared with other objects.