StackOverFlow

As we learned in the previous section, stack is the home of the parameters and local variables of an object which have references to that object on the heap. Heap and stack are important parts of memory allocated to JVM. Each thread created by your program gets its own stack and this memory is limited by its creator thread. As you learned earlier, when we call a method, JVM reserves a block on top of the stack where it stores local variables. And if our method fills up this allocated block, JVM throws an StackOverFlow error.

There are many possibilities for getting an StackOverflow error; however, having a recursive call without any proper termination condition is a very common reason. As you may have figured out, a recursive ...

Get Java 9 High Performance now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.