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.