I want to know what is the maximum number of (recursive)function calls allowed in gcc C. I have a program which can take stack depth of 400000 function calls each with size of around 200 bytes (so around 80 MB). How can I increase the maximum depth?
-
3Are you sure you want to go deeper? That's a lot of recursion, I think. You might try making it iterative.GManNickG– GManNickG2009-10-11 05:27:40 +00:00Commented Oct 11, 2009 at 5:27
-
I am doing memoization for DP. Its a problem on 3 by 3 matrix , converting one config to other config. I cant make it iterative.avd– avd2009-10-11 05:31:07 +00:00Commented Oct 11, 2009 at 5:31
-
1@aditya: all recursive algorithms can be made iterative; it is often hard to do so and you may not know how to do it.Jonathan Leffler– Jonathan Leffler2009-10-11 05:51:32 +00:00Commented Oct 11, 2009 at 5:51
Add a comment
|
2 Answers
I would recommend rewriting the routine into an iterative algorithm. Though nontrivial it should be straightforward to convert the algorithm, and will free you from having to deal with such resource limitations (which, I would guess, vary wildly by architecture, platform, computer details, etc.)
Also, please note: all recursive algorithms can be written iteratively.
1 Comment
avd
I am doing memoization for DP. Its a problem on 3 by 3 matrix , converting one config to other config. Making iterative is difficult.