O'Reilly logo

C# 5.0 Unleashed by Bart De Smet

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required