The .NET Framework allocates less memory for a Int32
than for a Int64
in 64 bit systems?
views:
105answers:
3No, they consume the same amount of space, since the smallest addressable space is 64 bits.
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.