/
What is the stack?

What is the stack?

And how do we allocate memory on it? The stack is where a computer pushes function parameters on to before calling a function. Last in first out.

A function will pop it’s parameters off the stack, the function can return values by pushing it’s result on to the stack.

If we use up too much stack space we get a “stack overflow” which when we overflow the stack.

The efficiency of allocating memory on the stack is very fast - there no complex algorithms like searching for a block in the heap that has to be made.

Related content

Heap and stack - understanding memory allocation
Heap and stack - understanding memory allocation
More like this
C/C++Stack Variables
C/C++Stack Variables
More like this
What is the heap?
What is the heap?
More like this
How does malloc work?
How does malloc work?
More like this
What are threads?
What are threads?
More like this
Functions
More like this