A question arised when I was programming a recursive function in Haskell; Can any call stack in any language (or just Haskell) run out of memory at a particular point?
Thanks 🙂
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You have a finite amount of memory, and if each frame on the call stack takes a non-zero number of bytes (tail-call optimization makes this a little more complex), you must be able to exhaust the resource with a deep enough recursion. Basic logic.
That said, how deep you can go does depend on the implementation of the stack. Where the stack is implemented in the normal interrupt stack (also called the C stack due to its association with that language), you have quite a limited space available, enough to get pretty deep with small frames but really limited when the frame size goes up (with more variables of larger types). Not all languages use the interrupt stack, instead locating their stacks in heap space (much larger).