Instance size

  • Thread starter Thread starter Ramona van Riet
  • Start date Start date
R

Ramona van Riet

How can I find out what the *instance* size of an object is? I know i can
use sizeof() on value types, but using it on an objhect reference only
gives me 4, which simply means that the reference is a 4 byte pointer.

How can I find out how big the referenced object is, i.e. the total size
of all private, protected and public members and hidden members, like
virtual method tables, interface reference tables, etc.? I have browsed
the online help, but couldn't find anything yet.
 
Ramona,

This has been discussed before. Someone who wanted to know the same
thing as you ended up, after many posts by other people, realizing
that it is just not possible to know the size of any class instance.
For a special class, I suppose you could build this kind of
functionality up, but there is no easy solution to getting the
equivalent of SizeOf() for reference objects.

For other ideas (besides mine which is no idea at all) do a google
search for "sizeof" and you'll come across all sorts of answers.

Scott

here's the google search I did:
http://groups.google.com/groups?as_...p=microsoft.public.dotnet.*&lr=&num=100&hl=en
 
Scott said:
Ramona,

This has been discussed before. Someone who wanted to know the same
thing as you ended up, after many posts by other people, realizing
that it is just not possible to know the size of any class instance.
For a special class, I suppose you could build this kind of
functionality up, but there is no easy solution to getting the
equivalent of SizeOf() for reference objects.

For other ideas (besides mine which is no idea at all) do a google
search for "sizeof" and you'll come across all sorts of answers.

I was afraid I'd get that answer. I'll google a bit, but what you say
confirms my expectations. :-(

Thanks for taking the time to answer my question.
 
Back
Top