How do I evaluate, in c#, the amount of memory taken up by any
Neither binary serialization nor marshalling will actually tell you
that information, and there's no way to determine it accurately, in a
guaranteed way.
However, each object has an 8 byte "overhead" plus the space taken for
its member fieds. Each reference is 4 bytes (on a 32 bit CLI), each
Int32 takes 4 bytes, etc. Where it becomes tricky is if you have
byte/short members - depending on attributes, these members may be
"packed" or not.
Don't forget though that two objects could both refer to the same third
object - you'd have to make sure you don't count that third object
twice if you're trying to sum the object sizes...
Jon