问题描述
我将 MinGW 与 GCC 3.4.5(mingw-special vista r3)一起使用.
I'm using MinGW with GCC 3.4.5 (mingw-special vista r3).
我的 C 应用程序使用了很多堆栈,所以我想知道有什么方法可以通过编程方式告诉我还剩下多少堆栈,以便在我发现我即将用完时可以干净利落地处理这种情况.
My C application uses a lot of stack so I was wondering is there any way I can tell programatically how much stack is remaining so I can cleanly handle the situation if I find that I'm about to run out.
如果不是,您还有什么其他方法可以解决可能用完堆栈空间的问题?
If not what other ways would you work around the problem of potentially running out of stack space?
我不知道我将从多大的堆栈开始,所以还需要以编程方式识别它.
I've no idea what size of stack I'll start with so would need to identify that programatically also.
推荐答案
Raymond Chen (老New Thing) 对这类问题有很好的回答:
Raymond Chen (The Old New Thing) has a good answer to this sort of question:
如果你不得不问,你可能做错了什么.
以下是有关堆栈分配的一些 Win32 详细信息:MSDN.
Here's some Win32 details on stack allocation: MSDN.
如果您认为您可能会受到堆栈空间的限制,那么您几乎肯定会受到可用虚拟内存的限制,在这种情况下,您需要找到不同的解决方案.
If you think you might be limited by stack space, you will almost certainly be limited by available virtual memory, in which case, you will need to find a different solution.
你到底想做什么?
这篇关于检查 C 中可用的堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!