Tutorial :In 64 bit systems, a 32 bit variable occupies less space than a 64 bit object?



Question:

The .NET Framework allocates less memory for a Int32 than for a Int64 in 64 bit systems?


Solution:1

Int32 and Int64 should consume the same space on all platforms (meaning an Int32 consumes the same amount as another Int32 on both x86 and x64). On all platforms, Int32 should consume different amount than Int64.

However, both Int32 and Int64 are poor examples, since they are structs. Objects consume significantly different space on x64 vs. x86, because they are basically pointers and pointers on x64 are twice as wide as on x86. This applies to function addresses, jump addresses, vtables, call instructions and so on and so forth. An x64 compiled application, and a IL application JIT code for x64 will be significantly larger than its x86 counterpart. It used to be also that the x86 code generation was more mature and optimized more aggressively simply because the compilers were more mature (this applied to JIT code generation as well) but the compiler caught up and now days the x64 optimizations are on-par, if not better than x86 ones.


Solution:2

No, they consume the same amount of space, since the smallest addressable space is 64 bits.


Solution:3

http://www.simple-talk.com/dotnet/.net-framework/object-overhead-the-hidden-.net-memory--allocation-cost/

http://social.msdn.microsoft.com/Forums/en-US/clr/thread/b4839085-772b-4925-a0f6-2fe21096c376/


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »