Wednesday, May 30, 2007

StackOverflow

I am pretty sure a lot of programmers encountered the StackOverflow error.
To be frank, in my early programming adventures, i never thought too much about the stack. 'Just another theory thing', i thought. But then, i learned my lessons.

Now, there ain't a lot of ways to cause stack overflows, but if you are really feeling itchy, the following mistake will certainly create it.


public void methodB()
{
methodA();
}

-- Call one of these methods --
public void methodA()
{
methodB();
}
But usually when i create stackoverflows, its usually because i call such recursive methods which are residing in different classes. So be careful, u never know when you create such a situation in the jungle of code.

No comments: