某个程序的堆栈内存有多大,是否有任何编译器标志可以设置它? [英] How big is the stack memory for a certain program, and are there any compiler flags that can set it?

查看:23
本文介绍了某个程序的堆栈内存有多大,是否有任何编译器标志可以设置它?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

正如标题所述:关于堆栈大小是否有任何一般的经验法则".我猜大小会因操作系统、架构、缓存大小、可用 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).

  • For Microsoft Visual C++, use the /F option to change the size, and DUMPBIN /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.

这篇关于某个程序的堆栈内存有多大,是否有任何编译器标志可以设置它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆