Given an object of a Java class, is there some straightforward way to
find out how many bytes of memory it takes up?
In C there exists a <sizeof()> operator, but even if it had a counter-
part in Java (which doesn't appear to be the case) that wouldn't be
exactly what I want because the objects I want to know the sizes of
contain references to objects of other classes, and I need to know the
_total_ bytes taken up by that object, its components, its components'
components, and so on. Can anybody point me to how I can find this
out? Any information would be greatly appreciated.
---Kevin Simonson
"You'll never get to heaven, or even to LA,
if you don't believe there's a way."
from _Why Not_
Daniel Dyer - 03 Nov 2006 22:56 GMT
> Given an object of a Java class, is there some straightforward way to
> find out how many bytes of memory it takes up?
[quoted text clipped - 6 lines]
> components, and so on. Can anybody point me to how I can find this
> out? Any information would be greatly appreciated.
This is a frequently-asked question and has been covered on here a few
times in the last month or so. There was even a JavaWorld link posted by
Hendrik Maryns today. If you search the c.l.j.p Google Groups archive for
'sizeof' you should find something.
Dan.

Signature
Daniel Dyer
http://www.uncommons.org
Arne Vajhøj - 03 Nov 2006 23:11 GMT
> This is a frequently-asked question and has been covered on here a few
> times in the last month or so. There was even a JavaWorld link posted
> by Hendrik Maryns today. If you search the c.l.j.p Google Groups
> archive for 'sizeof' you should find something.
The last one started October 25th and the subject
is "Memory Footprint of an Object".
Arne