Is there a limit on the stack size of a process in Linux? Is it simply dependent on the RAM of the machine?
I want to know this in order to limit the depth of recursive calls to a function.
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.
The stack is normally limited by a resource limit. You can see what the default settings are on your installation using
ulimit -a:(this shows that mine is 8MB, which is huge).
If you remove or increase that limit, you still won’t be able to use all the RAM in the machine for the stack – the stack grows downward from a point near the top of your process’s address space, and at some point it will run into your code, heap or loaded libraries.