StackOverflowException
Besides the heap memory, there’s another finite resource in an application: its stack used to keep track of local variables, method calls, and evaluation of expressions. When this resource gets exhausted, a StackOverflowException results. Again, this is one of the exception types that’s uncatchable because properly dealing with such a circumstance is far from trivial. (You shouldn’t cause any further stack usage doing so.)
Typically, a StackOverflowException indicates an unbounded recursive algorithm in your code (which is a bug) or the fact you’re processing “deep” recursive data structures. Let’s take a look at a few examples:
void BlowUp() { BlowUp();}
Depending on the amount of state kept for every frame on the call ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access