tags:

views:

118

answers:

3

Apologies if this has been asked before - searching SO for the terms "object reference" primarily returns page after page of questions about NullReferenceException.

What is the size of an object reference in .Net? Does it vary between x86, x64, and/or AnyCPU compilation?

If it makes a difference, I'm personally interested in C#.

A: 

see related question

Tim Hoolihan
That is related, but definitely not the same question. Thanks for the link!
arootbeer
Shouldn't this just be a comment then?
Brian Rasmussen
+8  A: 

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.

Sam
That's what I figured - I just wanted to make sure there wasn't more going on inside the runtime
arootbeer
+1  A: 

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.

Igor Zevaka