Skip to main content

StackOverflowError

Learn StackOverflowError (JVM Problems, Java) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

6. Basic Concepts What is StackOverflowError? Every time a method is called, the JVM pushes a new stack frame onto that thread's call stack, to remember local variables, parameters, and where to return to. Each thread's stack has a fixed maximum size. java.lang.StackOverflowError is thrown when a thread's call stack grows beyond that limit - almost always because of a method calling itself (directly or indirectly) too many times without stopping, i.e. uncontrolled recursion . Like OutOfMemoryError, it is a subclass of java.lang.Error , not Exception.

More lessons in JVM Problems