Stackoverflow on StreamCore

Hello all,

Sometimes, when I stop my application in the debugger in unrelated parts of the code, I get StackOverflow errors on the livestream renderer. Is there any obvious reason this can happen?

D/Error: ERR: exClass=java.lang.StackOverflowError
ERR: exMsg=stack size 1037KB
ERR: method= line=114
ERR: stack=java.lang.StackOverflowError: stack size 1037KB

A StackOverflowError is a runtime error in java. It simply signals that there is no more memory available. It extends the VirtualMachineError class, which indicates that the JVM (Java Virtual Machine) is broken, or it has run out of resources and cannot operate. A common case of a StackOverflowError being thrown, is when call stack exceeds due to excessive deep or infinite recursion.

Here’s an example:

public class Overflow {
    public static final void main(String[] args) {

That function calls itself repeatedly with no termination condition. Consequently, the stack fills up because each call has to push a return address on the stack, but the return addresses are never popped off the stack because the function never returns, it just keeps calling itself.

The simplest solution is to carefully inspect the stack trace and detect the repeating pattern of line numbers. These line numbers indicate the code that is being recursively called. Once you detect these lines, look for the terminating condition (base condition) for the recursive calls.

1 Like

Recursion is so much fun.

I doubt that’s root cause for this.

He’s suspending a thread via a debugger. The likely root cause is the umpteen thousand frame updates that got queued as the main thread was suspended.

Yes there was an endless recursion on my code :frowning: I corrected it eventually. The root cause of why it was visible was indeed because the queue exploded due to lack of consumption while the debugger was stopped. Thanks @synman @walemark.