Stack overflow

The call stack may consist of a limited amount of address space, often determined at the start of the program.

The size of the call stack depends on many factors, including the programming language, machine architecture, multi-threading, and amount of available memory.

[2] However, some compilers implement tail-call optimization, allowing infinite recursion of a specific sort—tail recursion—to occur without stack overflow.

In contrast, the function at the right must only store 3 integers at any time, and computes an intermediary result which is passed to its following invocation.

For this reason some authors recommend that arrays larger than a few kilobytes should be allocated dynamically instead of as a local variable.