堆栈内存位置
我知道堆内存是RAM的一部分。 但是堆栈内存也是RAM的一部分,或者堆栈内存是CPU寄存器的一部分。 .net4.0应用程序的堆栈内存的默认大小是多少
i know the heap memory is the part of ram.
but is stack memory also the part of ram or stack memory is the part of cpu registers.
what is the default size for stack memory for .net4.0 applications
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
堆栈存储器是 RAM 的一部分。就计算机而言,它与堆没有什么不同。它只是以不同的方式使用。
The stack memory is a part of RAM. It is no different from the heap as far as the computer is concerned. It's only used in a different way.
通常,程序代码空间和堆内存是从内存空间的底部(从零开始)向上分配的。通常,堆栈从内存空间的最顶部开始并向下增长。初始堆栈大小可以非常小(一页),因为当您超出它时,就会发生页面错误,并且操作系统可以分配更多空间,向下增长。
顺便说一句,在 64 位 x86 处理器中,64 位地址空间中间有一个很大的“间隙”,因为机器没有实现完整的 64 位寻址。请参阅维基百科上的内容。
Typically, program code space and heap memory are allocated from the bottom (starting at zero) of the memory space, on up. Commonly, stacks start at the extreme top of the memory space and grow downward. The initial stack size can be very small (one page), because when you outgrow it, a page fault will occur, and the OS can allocate more space, growing downward.
Incidentally, in 64-bit x86 processors, there is a big "gap" in the middle of the 64-bit address space, because the machine doesn't implement full 64-bit addressing. See this on wikipedia.
这对于 .Net 和非 .net Windows 应用程序很常见。它是按线程分配的。每个线程都有自己的堆栈。典型大小为 1 MB。可以覆盖默认值:
/STACK
选项,因此如果您使用 C++/CLI 创建 .NET 可执行文件,则可以设置该选项。显然,在 C# 或 F# 中没有选项可以控制它。This is common for .Net and non-.net Windows applications. It is allocated per-thread. Each thread has its own stack. The typical amount is 1 MB. The default can be overridden:
/STACK
option in C++ compiler, so you can set that if you use C++/CLI to create .NET executables. Apparently, there's no option to control that in C# or F# though.System.Threading.Thread
has a constructor overload that takes stack reservation as one of the parameters.