gpt4 book ai didi

c# - StackOverflowException 即使在增加堆栈大小之后

转载 作者:太空狗 更新时间:2023-10-29 20:42:46 24 4
gpt4 key购买 nike

我有一个以 x86 模式运行的 C# WinForm 应用程序。它适用于 x86 模式。当我以任何 CPU 模式运行此应用程序时出现问题。我收到以下提到的错误:

An unhandled exception of type 'System.StackOverflowException' occurred in XXXXXX.dll

我知道这可能是由无限循环引起的,在那种情况下 x86 模式下应该会发生同样的错误。我知道这不是因为无限迭代。它与堆栈溢出有关。

在做了一些研究之后,我使用 Editbin 增加了堆栈大小

来自

Editbin.exe /Stack:14000000 "$(TargetDir)MyProject.exe"

Editbin.exe /Stack:14000000 "$(TargetDir)MyProject.exe"

知道可能是什么原因以及我应该去往什么方向吗?

最佳答案

My bathtub is overflowing.

尝试换一个更大的浴缸。

OK, I did that. My bathtub is still overflowing.

试着换一个更大的浴缸。

OK, it's still overflowing! I have a huge bathtub but it is still overflowing!


如果问题出在下水道堵塞和水龙头开着,换一个更大的浴缸也无济于事。

您的问题很可能是您的程序试图消耗无限 量的堆栈。让堆栈变大无济于事。

I know this could be because of infinite loops and what not but the same error should occur in the x86 mode in that case.

这个说法是错误的。不要求出现相同的错误。

Why is it different depending on whether or not I'm targetting a particular cpu?

抖动在不同的场景下会产生不同的代码,有时会产生将无限递归变成无限循环的代码。那些不会消耗无限堆栈,但它们会永远运行。

Suppose for the sake of argument that there is no unbounded recursion.

那么有可能存在非常的递归。由于 64 位代码比等效的 32 位代码可以占用更多的堆栈空间,因此大型递归会导致堆栈外错误更早发生。

在那种情况下,增大堆栈不是一个好主意。相反,找到深度递归算法并将其变成迭代算法。

关于c# - StackOverflowException 即使在增加堆栈大小之后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15485908/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com