> This is true, but the presence of code turns out to be irrelevant.

Yes, I should have made this clearer.  Of course the presence of code does
have a one-off cost which you will pay when the assembly gets loaded and
when methods get JITted, but as you say this does not affect the size of
each object instance.

Something else to mention: normally the CLR optimises the packing of member
data, but [StructLayout] can override this behaviour causing each instance
to consume more memory.  Due to the way the Microsoft compilers default
[StructLayout], this means a class and a struct with the same data members
could occupy different amounts of memory per object.

--
Ivan Towlson
White Carbon

Reply via email to