karthikbalaguru said:
Hi,
I have 1 GB RAM and i use Fedora Core.
How many calls can be called recursively so that my stack does not get
corrupted ?
Any ideas ?
This is system-specific and not about the C language per se, so I'm
crossposting and setting followups to comp.os.linux.development.apps.
It's not really possible to say exactly, but you can get a rough idea.
First, estimate how much stack space is needed by each call; it should
be approximately equal to the total size of all local variables and
parameters in the function, plus another 8 or 16 bytes or so for the
return address and saved frame pointer.
Next, figure out how much total stack space is available to your
process. Running `ulimit -s' in bash will give you the number in KB. 8
MB is a common default. You can adjust it (for that shell and its
descendants) by giving an argument to `ulimit -s'. You can also say
`ulimit -s unlimited' to allow the stack to grow arbitrarily, limited
only by available memory and swap, and by possibly running into other
parts of the program's memory.
Divide these two numbers.