Linux 32位计算机上的程序的堆栈分配限制 [英] Stack allocation limit for programs on a Linux 32 bit machine
问题描述
在C ++中,堆栈段在编译器放弃之前会增长多少,并且说它不能为堆栈分配更多的内存。
In C++ how much can the stack segment grow before the compiler gives up and says that it cannot allocate more memory for stack.
在linux(fedora)32位机器上使用gcc。
Using gcc on a linux (fedora) 32 bit machine.
推荐答案
p>在UNIX下,如果您正在运行bash run
Under UNIX, if you are running bash run
$ ulimit -a
它会列出各种限制,包括堆栈大小。矿是8192kb。您可以使用ulimit更改限制。
it will list various limits including stack size. Mine is 8192kb. You can use ulimit to change the limits.
此外,您可以使用ulimit()函数设置程序中的各种限制。
Also, you can use ulimit() function to set various limits from within your program.
$ man 3 ulimit
Windows请参阅 StackReserveSize 和 StackCommitSize
Under Windows see StackReserveSize and StackCommitSize
实际上,堆栈地址从高地址开始(在32位平台上,接近3GB限制),而在低地址开始内存分配时减少。这允许堆栈和内存增长,直到整个内存耗尽。
In practice stack addresses begin at high addresses (on a 32-bit platform, close to the 3GB limit) and decrease while memory allocation begins at low addresses. This allows the stack and memory to grow until whole memory is exhausted.
这篇关于Linux 32位计算机上的程序的堆栈分配限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!