什么是可空&LT的内存占用; T&GT; [英] What is the memory footprint of a Nullable<T>
本文介绍了什么是可空&LT的内存占用; T&GT;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是 INT
(的Int32
)的4字节的内存占用。但是,什么是内存占用:
An int
(Int32
) has a memory footprint of 4 bytes. But what is the memory footprint of:
int? i = null;
和
int? i = 3;
这是一般或类型依赖?
Is this in general or type dependent?
推荐答案
我不是100%肯定,但我相信它应该是8个字节,4个字节为INT32,和(因为每一件事物都有为4-字节32位机器上对齐)的4个字节为一个布尔值,指示整数值是否已经被指定与否。
I'm not 100% sure, but I believe it should be 8 Bytes, 4 bytes for the int32, and (since every thing has to be 4-Byte aligned on a 32 bit machine) 4 bytes for a boolean indicating whether the integer value has been specified or not.
在一个64位的机器仍然会是8字节(64位),因为这是内存的最小块,也可以得到解决......
On a 64 Bit machine it would still be 8 bytes (64 bits) since that is the smallest chunk of memory that can be addressed...
这篇关于什么是可空&LT的内存占用; T&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文