C# Recursion Depth - How Deep can you go?

I've incresed stack size during some documents recognition. It was really need.

I've incresed stack size during some documents recognition. It was really need. 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.

3 +1 Every recursive algorithm can be written as non recursive with a loop and a stack data structure. – Byron Whitlock Dec 22 '10 at 20:35 2 @Byron: Thanks for making me remember my data structures class in college. Prof: "Write this tree-traversal program in a non-recursive format."

Me: "Why do you hate us? " : ) – Norla Dec 22 '10 at 20:40 My question was how to do it, I was more curious than wanting to actually do it. While this is good advice, it doesn't answer the question as posed.

– Keith Nicholas Dec 23 '10 at 1:49.

The default stack size is stored in the PE header. If you spawn the thread yourself, Thread has a constructor that takes the stack size as a parameter. However, the default .

NET stack size of 1 MB should be enough for most tasks, so before you change it you should at least review the task.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions