Have you ever tried to suspend one thought, to think of something else relevant first?
Imagine that you want to by groceries, so you need to drive to the supermarket, so you need to start your car, so you need to get your keys, so you need to search your pockets, and technically you are now 4 nested-tasks deep in your plan to buy groceries.
A computer sometimes has to do nested tasks like this too (but usually dealing with data, like to do a calculation it needs to know some some numbers, but that numbers requires some arithmetic, and that arithmetic requires looking up some data, etc etc).
When a computer is nesting these tasks, it stores its memory of what it was doing on a virtual ‘stack’, and keeps trying to solve the problem that is on top of the stack.
The computer has a limited amount of memory, so if the task is nested too many times, the ‘stack’ will overflow beyond the memory it uses to organise this ‘stack’. It doesn’t know what to do in that case, and so to be safe the program will crash and simply stop running.
Latest Answers