Stack Allocation

Noun · Development

Definitions

  1. The practice of allocating memory on the call stack by simply adjusting the stack pointer, making allocation and deallocation essentially free (a single instruction). Stack-allocated variables are automatically freed when the function returns, require no garbage collection, and have excellent cache locality — but are limited in size (typically 1–8 MB per thread) and cannot outlive the enclosing scope.

    In plain English: Storing data in a fast, automatically managed section of memory that gets cleaned up the moment a function finishes.

    Example: "That struct is small and doesn't escape the function, so the compiler stack-allocates it — zero GC pressure."

Related Terms