Question

With the StackOverflowException are the conditions to be thrown hardcoded or dependent on the machine the code is running on?

I am almost certain the latter but have failed in my searches and don't ask enough questions here.

Was it helpful?

Solution

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. If I remember correctly, it is 1MB in size by default.

OTHER TIPS

Although not a perfect match for your question, see also:

How do you change default stack size for managed executable.net

Stack frames will vary depending on the addressing mode of your OS. I believe x64 uses slightly larger stack frames. 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.

The exception that is thrown when the execution stack overflows because it contains too many nested method calls. This class cannot be inherited.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. 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. This class cannot be inherited.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top