On Windows XP using Visual C++ with 2GB of RAM, how many functions would have to be on the stack at the same time to create a stackoverflow? (i.e. in recursive functions)
Is there a simple way I could calculate this for other similar situations?
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.
There’s no way to know just from the compiler. Stack overflows happen because of overflowing the stack. The stack’s size grows depending on the arguments a function takes, local variables the function uses, and compiler optimizations. There are even some C99 functions I believe that will allocate space directly from the stack.
The limit of the stack’s size is determined by a compiler switch, not how much RAM you have in your computer. So how many calls it takes to overflow has more to do with compiler settings than your memory.
It’s not something you can determine a priori. At least, not trivially.