NOTE: Internet Information Services is a multi-threaded web application platform that allows application code running inside of each worker process to utilize hundreds or more threads at once as necessary. Each thread is bound by the same stack size limit in order to keep the virtual memory usage of the process within manageable limits.
The arguments and the local variables of a function are stored in the stack of the thread. If you declare a local variable that has a very large value, the stack is quickly exhausted. For example, the function in the following code example requires 400,000 bytes in the stack to store the array.
// Use 100,000 integers multiplied by 4 bytes per integer to store the array.
To avoid using the stack, dynamically allocate the memory. For example, the function in the following code example dynamically allocates the memory.
i = new int;
// More code goes here.
If a function is called recursively, the stack may be quickly exhausted. For example, a function requires 400,000 bytes in the stack if the following conditions are true:
- The function requires 40 bytes for a local variable.
- The function is recursively called 10,000 times.
For more information, visit the following MSDN Web site: