Eli5-What does a “stack overflow” mean?

1.23K views

Eli5-What does a “stack overflow” mean?

In: 847

41 Answers

Anonymous 0 Comments

You’re reading a Choose Your Own Adventure book e.g. “To call a taxi, turn to page 23. To take the bus, turn to page 34”.

You only have five bookmarks labeled #1 through #5.

You want to read every possible outcome.

Your plan: Every time you reach a choice, you place the next bookmark, starting with #1. When you reach a dead end, you go back to the last bookmark you placed. When all the options are exhausted, you remove the bookmark.

As you’re reading, you reach a choice, and you realize you have no more bookmarks left. What if you decided to continue writing page numbers on a piece of paper you found? Uh oh, you accidentally wrote over your homework and now you’ll fail the class.

The book is like a computer program. Every choice in the book is called a “call” or “jump”. The bookmarks are called a “call stack.” You might be saying: “The bookmarks don’t look like a stack.” It doesn’t have to. All that matters is the last item placed is the first item removed. This is called “Last In, First Out” (LIFO). If you chose to use another piece of paper, that’s called a “stack overflow.” But you run the risk of clobbering data used for something else.

Instead, you ask for help. So you yell, “Mom, I need more bookmarks!”

Your mom is the operating system. When you yelled, you raised what is called a “stack overflow exception”, which means you can’t continue.

You hope that your mom simply gives you more bookmarks. Unfortunately, like most operating systems, she throws your book away and tells you to clean your room.

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