Value types in object stored in heap as well?(对象中的值类型也存储在堆中?)
问题描述
我可以想象这个问题已经被问了数千次,但我没有太多运气找到答案,而且这更多是出于好奇而不是需要.
I can imagine this question has been asked thousands of times, but I didn't have much luck in finding the answer, plus this is more out of curiosity than need.
深入研究 C# 的具体细节,我想知道既然对象存储在堆中,那么对象中的值类型是否也存储在堆中还是放在堆栈中?
Digging into the nuts and bolts of C#, I was wondering since objects are stored in the heap, are the value types within the objects stored in the heap as well or are they placed in the stack?
推荐答案
它们存储在堆中,在为引用类型分配的内存中.此外,值类型通常存储在the堆栈".但是,CLI 规范没有指定存储值类型的内存池所在的位置 - 这是一个无关紧要的实现细节.
They are stored in the heap, inside of the memory allocated for the reference type. In addition, value types are often stored in places other than "the stack". However, the CLI spec does not specify where the memory pool that stores value types resides - it's an implementation detail that should not matter.
这篇关于对象中的值类型也存储在堆中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:对象中的值类型也存储在堆中?


基础教程推荐
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- 如何激活MC67中的红灯 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01