How big is the stack memory for a certain program, and are there any compiler flags that can set it?(某个程序的堆栈内存有多大,是否有任何编译器标志可以设置它?)
问题描述
正如标题所述:关于堆栈大小是否有任何一般的经验法则".我猜大小会因操作系统、架构、缓存大小、可用 RAM 大小等而有所不同.
As the title states: Is there any general "rule of thumb" about the size of the stack. I'm guessing the size will vary depending on the OS, the architecture, the size of the cache(s), how much RAM is available etc.
但是一般来说可以说什么,或者有什么方法可以找出,这个程序允许使用多少堆栈?.作为一个额外的问题,是否有任何方法(使用编译器标志等(这里主要考虑 C/C++,但也更通用))堆栈的大小可以由用户设置为固定大小?
However can anything be said in general, or is there any way to find out, how much of the stack, this program is allowed to use?. As a bonus question is there any way (with compiler flags etc. (thinking mostly C/C++ here, but also more general)) that the size of the stack can be set to a fixed size by the user?
顺便说一句,我完全出于好奇而问,我没有堆栈溢出.:)
Btw, I'm asking strictly out of curiosity, I'm not having a stack overflow. :)
推荐答案
是的,你可以设置堆栈大小,它通常是一个链接器标志,它取决于你的工具链(通常由编译器的名称引用).
Yes you can set the stack size, it usually is a linker flag, and it depends on your toolchain (typically this is referred to by the name of the compiler).
- 对于 Microsoft Visual C++,使用
/F
选项 来改变大小,DUMPBIN/HEADERS
看看什么设置是. - 对于 GCC 工具链和大多数其他 Unix 链接器,使用
-Wl,--stack
- For Microsoft Visual C++, use the
/F
option to change the size, andDUMPBIN /HEADERS
to see what the setting is. - For the GCC toolchain and most other Unix linkers, use
-Wl,--stack
您还可以在 StackOverflow 上找到几个现有问题.
You will also find several existing questions here on StackOverflow.
这篇关于某个程序的堆栈内存有多大,是否有任何编译器标志可以设置它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:某个程序的堆栈内存有多大,是否有任何编译器


基础教程推荐
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 常量变量在标题中不起作用 2021-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 我有静态或动态 boost 库吗? 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01