As according to the
javadocs, it is "Thrown when a stack overflow occurs because an application recurses too deeply."
So, typically, this will happen when you have made a recursive function that never ends.
This question has nothing to do with performance (even though you added that in the subject), moving to
Java - Beginner forum.