Search code examples
clrstackreference-type

What's the size of a reference on the CLR


I was (purely out of curiosity) trying to find out what the size of an actual reference is when an allocation is made on the stack.

After reading this I still don't know (this answers it only for value types or type definitions), and I still cannot seem to find it anywhere.

So basically imagine a class as follows

class A
{
    string a;
}

Now when an object of type A is instantiated, a reference to the string object would be stored on the stack, now what would the size of the allocation on the stack be?

Disclaimer: If I'm talking complete and utter nonsense please let me know :)


Solution

  • Just like the size of pointers, presumably, the size would be that of a native int: 32-bits on 32-bit platforms and 64-bits on a 64-bit platform.