The title says it all.
For example a pointer to a class:
Or a gameObject:
Thanks in advance.
asked Feb 28 '10 at 11:45 PM
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.
answered Mar 01 '10 at 05:37 AM
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.
answered Dec 01 '10 at 05:06 AM
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.
answered Mar 01 '10 at 01:39 AM
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.
answered Mar 01 '10 at 04:31 AM
i want to know to store a pointer variable how much memory is required
answered Mar 02 '10 at 06:50 AM