Why on modern Linux, the default stack size is so huge - 8MB (even 10 on some distributions)

As others have said, and as is mentioned in the link you provide in your question, having an 8MiB stack doesn’t hurt anything (apart from consuming address space — on a 64-bit system that won’t matter).

Linux has used 8MiB stacks for a very long time; the change was introduced in version 1.3.7 of the kernel, in July 1995. Back then it was presented as introducing a limit, previously there wasn’t one:

Limit the stack by to some sane default: root can always increase this limit if needed.. 8MB seems reasonable.

On Linux, the stack limit also affects the size of program arguments and the environment, which are limited to one quarter of the stack limit; the kernel enforces a minimum of 32 pages for the arguments and environment.

For threads, if the stack limit (RLIMIT_STACK) is unlimited, pthread_create applies its own limits to new threads’ stacks — and on most architectures, that’s less than 8MiB.


8MB is the virtual size of the stack. A page fault will happen when your application tries to use more stack than is currently physically allocated. The kernel's page fault handler will then allocated a physical page and then your application will continue.

See https://unix.stackexchange.com/a/280865/21212 for a complete explanation.

So reducing your stack size should have no effect in reducing physical memory usage of your application.