How much memory does a pointer use?

The title says it all.

For example a pointer to a class:

 MyClass pointer = new MyClass ();

Or a gameObject:

 GsmeObject pointer = gameObject;

Thanks in advance.

first of all these are references and not pointers. they have some differences. any ways, the size of a reference is so small. it's just an adress. in .NET size of all datatypes are the same in all systems and platforms. i think it's 64 bit in .NET but i am not sure. use the sizeof operator to get it and print it. if you want to calculate the size of an object i should say. all instances of a class share the code section (methods) but the data section (fields and properties) are seporate. the size of each object is the size of all of it's private/public//static variables.

Let me provide a little background for those who are interested.

In C/C++ the answer would be: For 32 bit software a pointer is 32 bits (4 bytes) For 64 bit software a pointer is 64 bits (8 bytes)

This is the whole point of 32 vs. 64 bit (pointer size). Most people know that a 64 bit OS will support more memory than a 32 bit OS. The reason is that the biggest number a 32bit value can hold is 2 ^ 32 = 4294967296 = 4 x 1024 x 1024 (4 GB)

So the largest memory address you can 'point' to with a 32bit pointer is 4GB. This prevents the OS from using any memory beyond that, that is where the limitation comes from. In practice you can only have 2 or 3 GB of RAM because some of those memory addresses are reserved for other memory including graphics card memory.

As for pointers/references in mono, it is possible that 32 bit platforms would use 64 bit pointers for portability. It wouldn't surprise me if they shoved some refcount, RTTI data and/or other metadata in there as well. So maybe they're a little bigger, but generally it is safe to consider the size to be negligable.

Well a pointer is just a memory address and as far as I know is usually just an unsigned int which on most systems is 2 bytes. The object itself however varies as you would need to add up the sizes of all the variables that the objects holds.

Ryan Zec is correct, a pointer is a trivial amount of memory (unless you are using astronomical numbers of them). What it points to can be any amount though.

i want to know to store a pointer variable how much memory is required