finding total number of bytes an object takes up

K

kvnsmnsn

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_
 
D

Daniel Dyer

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.

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

Guest

Daniel said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top