Phil Jones <ph************@hotmail.com> wrote:
Is there a way to determine the size (number of bytes) of an object?
I figure this can be done by serializing the object to disk and measuring
the file size - but I definately don't want to do this for performance
reasons. I'm hoping there is some Framework class that dishes up the
in-memory size of an object.
You really need to define exactly what you mean by the in-memory size
of an object. Most objects refer to other objects, for instance. If you
had two objects of class Foo, declared below, but they both referred to
the same large string, what would the size of each object be? Just the
size needed to store the string reference but not the string itself, or
the size needed to store everything?
class Foo
{
string bar;
}
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too