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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access