开发者

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

开发者 https://www.devze.com 2022-12-22 23:22 出处:网络
The .NET Framework allocates less memory for a Int32 than f开发者_StackOverflowor a Int64 in 64 bit systems?Int32 and Int64 should consume the same space on all platforms (meaning an Int32 consumes th

The .NET Framework allocates less memory for a Int32 than f开发者_StackOverflowor a Int64 in 64 bit systems?


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.


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


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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号