检查在C语言中的堆栈大小 [英] Checking available stack size in C

查看:636
本文介绍了检查在C语言中的堆栈大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用MinGW的使用GCC 3.4.5(MinGW的,特殊的远景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 (The Old New Thing) has a good answer to this sort of question:

如果你要问,你可能做得不对。

If you have to ask, you're probably doing something wrong.

下面是在栈上分配一些细节的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语言中的堆栈大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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