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

标签 .net vb.net sizeof primitive-types

查看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/

相关文章:

c# - 在 Linq 中使用匿名类型加入 2 个空字符串列表

c# - 从 float 转换为 TimeSpan

c# - 如何将 Postmark 用于 ASP.NET 登录控件?

c - 将原始结构内容(字节)写入 C 中的文件。对写入的实际大小感到困惑

c - 结构体指针的 malloc 为何有效?

C -> sizeof 字符串始终为 8

c# - 如何测试 API 请求和响应是否与 C# 中的 swagger 定义匹配

c# - Environment.GetFolderPath(...CommonApplicationData) 在 Vista 上仍然返回 "C:\Documents and Settings\"

vb.net - 如何在vb.net中读取文本文件中的重复字符串

vb.net - 我如何解决错误 ORA-06413 : Connection not open?