Home »

What size is a .NET object?

Question ListCategory: ASP.NETWhat size is a .NET object?
milleranthony7 author asked 8 years ago
1 Answers
jessica537 author answered 8 years ago

Each instance of a reference type has two fields maintained by the runtime -a method table pointer and a sync block. These are 4 bytes each on a 32-bit
system, making a total of 8 bytes per object overhead. Obviously the
instance data for the type must be added to this to get the overall size of the
object. So, for example, instances of the following class are 12 bytes each:

class MyInt
{

private int x;
}
However, note that with the current implementation of the CLR there seems
to be a minimum object size of 12 bytes, even for classes with no data (e.g.
System.Object).
Values types have no equivalent overhead.

Please login or Register to Submit Answer