How big is an object reference in .NET?
The reference itself is basically a pointer. 32 bits on a 32 bit OS, 64 bits on a 64 bit OS.
The size of the object that's referenced is more complicated.
For determining pointer size, you can use System.Runtime.InteropServices.Marshal.SizeOf(typeof(IntPtr))
, or sizeof(IntPtr)
in unsafe context.
Edit:
Or IntPtr.Size
.
An object reference is basically a pointer to the memory that contains the object's attributes. As such the reference is one processor word in length - 32 bits on 32 bit platforms and 64 bits on x64.