gpt4 book ai didi

.net - 在原始数据类型分配大小的上下文中, "Nominal storage allocation"是什么意思?

转载 作者:行者123 更新时间:2023-12-01 22:43:39 25 4
gpt4 key购买 nike

查看this table describing the data types in VB .

其中一列标有“Nominal storage allocation”。这是什么意思?为什么这里有“标称”这个词?

最佳答案

我相信在这种情况下,“标称”是指这些数据类型中包含的实际数据占用的字节数,不包括 CLR 用于跟踪值的任何存储,例如装箱值类型时发生的堆分配。

编辑

在阅读链接的文章时,我注意到以下部分:

Memory Consumption

When you declare an elementary data type, it is not safe to assume that its memory consumption is the same as its nominal storage allocation. This is due to the following considerations:

Storage Assignment. The common language runtime can assign storage based on the current characteristics of the platform on which your application is executing. If memory is nearly full, it might pack your declared elements as closely together as possible. In other cases it might align their memory addresses to natural hardware boundaries to optimize performance.

Platform Width. Storage assignment on a 64-bit platform is different from assignment on a 32-bit platform.

所以基本上这就是说每个值类型的总存储量是标称存储量 + 可用于在字边界对齐值的任何填充 + 可能的堆分配 - 同样,由运行时自行决定。

关于.net - 在原始数据类型分配大小的上下文中, "Nominal storage allocation"是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6886256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com