Eli5-What does a “stack overflow” mean?

1.27K views

Eli5-What does a “stack overflow” mean?

In: 847

41 Answers

Anonymous 0 Comments

Imagine you’re a computer, and your job is to count to 1000. However, while you’re in the midst of counting, I might interrupt you and ask you to recite the alphabet. When you’re done with the alphabet, you should continue where you left off with the counting.

In order to continue where you left off with the counting, you need to store which number you were on when you were interrupted. Let’s say you do this by writing it down on a slip of paper.

Now, imagine things get more complex. While you’re reciting the alphabet, I might interrupt you again and ask you to list all the states in the US in alphabetical order. And while you’re listing the states, I might interrupt you again and ask you to list all the planets in the solar system in order from their distance to the Sun. And so on.

Each time I interrupt you, you have to do as I ask, and when you finish a task, you need to go back to the previous task you were doing and finish that, and then the task before that, etc.

Each time you’re interrupted, you need to store the last thing you were doing before you were interrupted, so that you can resume it later. Since I might interrupt you multiple times, it would be convenient to put those slips of paper in a stack. That way, when you finish a task, you can take the top slip of paper and remember where you left off on that task.

Now, imagine that you only have 5 slips of paper to write things down on. If I interrupted you a 6th time, you’d run out of paper and wouldn’t be able to remember where you left off on the last task. Since you wouldn’t be able to add another slip of paper to the stack, you’d be in a stack overflow.

You are viewing 1 out of 41 answers, click here to view all answers.