Large recursions can cause errors outside the stack. Probably your problem is that your program is trying to consume an infinite amount / very large number of stacks.
Without seeing the stack trace, itโs a little difficult to give a final answer, but I think that sticking to the basics, I believe that the source of your StackOverflow is PsCmd + = , which continually pushes data onto the stack and throws a StackOverflowException.
You can increase the stack size using the code below:
Editbin.exe / Stack: 14000000 "$ (TargetDir) MyProject.exe"
Have you analyzed your code to see how deep your recursion is on average? Does it always get into StackOverflow? Try hardcoding one object and see the result.
Since 64-bit code can increase more stack space than equivalent 32-bit code, large recursions can lead to off-stack errors earlier.
In this case, making a stack is no longer a good idea. Instead, we must find a deeply recursive algorithm and turn it into an iterative one.
For Stack-Trace; You can read this property: Environment.StackTrace .
If stacktrace has reached the specified threshold, you can return the function.
Note. From .NET 2.0 and above, you cannot get a StackOverflowException object using a try-catch block.
Let me know if this helps you.
source share