Reputation: 18035
I have an object which is a composite of several other objects. When i use the getObjectSize() method in the Instrumentation package, does it include the size of the composite objects also?
Upvotes: 1
Views: 501
Reputation: 11454
No. The returned size reflects the size of that object - it includes the references that object holds, but not the size of the objects being referred to. (And, as others have noted, it's not guaranteed to actually be correct.)
Upvotes: 0
Reputation: 2446
getObjectSize(Object obj)
returns the storage consumed by the specified object (obj
)... so you will get the size of whatever you will specify.
Upvotes: -1
Reputation: 4574
The API doc says:
The result may include some or all of the object's overhead, and thus is useful for comparison within an implementation but not between implementations. The estimate may change during a single invocation of the JVM.
Upvotes: 0