views:

217

answers:

3

I'm getting "Program stack overflow RESET" message while running my program. So I set added a counter to see how many times I'm recursively calling the main function in my program. Turns out that it is around 30,000 times and the data I'm stacking are lists of length around 10 elements, which I think are not so many. My question is whether this amount of recursive call and memory usage are common or not, or is it more likely that I'm doing something wrong? I checked the resource manager of vista and found the memory only grew for like 1MB for lisp.exe process. And how do I adjust the stack overflow limit of CLisp?

+1  A: 

1 MB seems to be the default stack size on Windows. I do not know if it is possible to change it without relinking the program, but in any case I would recommend either converting the program to tail-recursive form and using the CLisp byte compiler, which will optimize it away, or just converting it to iterative form. While many Common Lisp compilers do implement tail call optimization, the standard does not require it, so unbounded recursion should not be used.

Ramarren
+2  A: 

I'm no expert on CLisp, but 30.000 calls for lists of 10 elements sound like most probably you created an infinite loop somewhere.

mh
This is better left as a comment. There are many applications in a functional-like language where this would make the most sense.
San Jacinto
Thanks for your advice. Since I was doing a search of some permutations of that list...so reducing 10! to 30000 is acceptable.
Simon
A: 

http://clisp.cons.org/impnotes.html#faq-stack

Note that if you do tail calls and compile your function(s) there will be no limit at all.

lnostdal