Is there any control how much you can Recursively call something?
From a basic test program I get a recursion depth of just over 18k
which depends on the stacksize....
is there a way to set up a chunk of memory (perhaps a thread) with a massive stack to increase recursion depth?
I've increased the stack size during some documents recognition. It was really needed.
So you can increase stack size for thread using following code:
var stackSize = 10000000; Thread thread = new Thread(new ThreadStart(BigRecursion), stackSize);
Thread(ThreadStart, Int32) -- Initializes a new instance of the Thread class, specifying the maximum stack size for the thread.
Source
Hope this what you need.
I think you are risking problems here. It's hard to determine exactly how much stack a recursive algorithm will use. And, if you are to the point where there's some question about if there'll be enough, I'd look for another approach.
Most recursive algorithms could be rewritten to not be recursive. You can then allocate as much memory as you need and even recover gracefully if there's not enough.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With