简体   繁体   English

StackOverflowException

[英]StackOverflowException

With the StackOverflowException are the conditions to be thrown hardcoded or dependent on the machine the code is running on? StackOverflowException是硬编码或依赖于运行代码的机器的条件?

I am almost certain the latter but have failed in my searches and don't ask enough questions here. 我几乎可以肯定后者,但我的搜索失败了,在这里没有提出足够的问题。

From the documentation : 文档

... is thrown when the execution stack overflows because it contains too many nested method calls. 当执行堆栈溢出时抛出...因为它包含太多嵌套方法调用。

Since the size of the stack is architecture-dependent and can even be overridden on a machine, yes, this value is not hard-coded, though it is generally pretty static on Windows. 由于堆栈的大小是依赖于体系结构的,甚至可以在机器上覆盖,是的,这个值不是硬编码的,尽管它在Windows上通常是非常静态的。 If I remember correctly, it is 1MB in size by default. 如果我没记错的话,默认情况下它的大小是1MB。

Although not a perfect match for your question, see also: 虽然不是您问题的完美匹配,但另请参阅:

How do you change default stack size for managed executable.net 如何更改托管的executable.net的默认堆栈大小

The exception that is thrown when the execution stack overflows because it contains too many nested method calls. 执行堆栈溢出时抛出的异常,因为它包含太多嵌套方法调用。 This class cannot be inherited . 这个类不能继承 MSDN MSDN

I tried this code with some changes. 我尝试了一些更改的代码 I alter above statement according to my experience 我根据自己的经验改变了上述陈述

Framework 4.0 The exception that is thrown when the execution stack overflows because it contains 7573 nested method calls. Framework 4.0 执行堆栈溢出时抛出的异常,因为它包含7573个嵌套方法调用。 This class cannot be inherited. 这个类不能被继承。

Framework 2.0 The exception that is thrown when the execution stack overflows because it contains 7038 nested method calls. Framework 2.0 执行堆栈溢出时抛出的异常,因为它包含7038个嵌套方法调用。 This class cannot be inherited. 这个类不能被继承。

Stack frames will vary depending on the addressing mode of your OS. 堆栈帧将根据操作系统的寻址模式而有所不同。 I believe x64 uses slightly larger stack frames. 我相信x64使用稍大的堆栈帧。 Keep in mind that the process space is capable of growing much more than on x86, so overall you should be able to configure your stack to accept more frames on x64, if RAM and swap file size are not an issue. 请记住,进程空间比x86增长得更多,所以总体而言,如果RAM和交换文件大小不成问题,您应该能够将堆栈配置为接受x64上的更多帧。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM