StackOverflowError when serializing an object in Java

Interesting post from Chen: When debugging a stack overflow, you want to focus on the repeating recursive part In your case: at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.defaultWriteFields(ObjectOutputStream.java:1509) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1474) at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1392) at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1150) at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:326) at java.util.ArrayList.writeObject(ArrayList.java:570) at sun.reflect.GeneratedMethodAccessor6.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at java.io.ObjectStreamClass.invokeWriteObject(ObjectStreamClass.java:945) at java.io.ObjectOutputStream.writeSerialData(ObjectOutputStream.java:1461) If you go hunting through your defect … Read more

How to overcome StackOverflowException bypassing unhandled exception handling in .NET

There are three kind of so-called “asynchronous exceptions”. That are the ThreadAbortException, the OutOfMemoryException and the mentioned StackOverflowException. Those excepions are allowed to occur at any instruction in your code. And, there’s also a way to overcome them: The easiest is the ThreadAbortException. When the current code executes in a finally-block. ThreadAbortExceptions are kind of … Read more

Why does the count of calls of a recursive method causing a StackOverflowError vary between program runs? [duplicate]

The observed variance is caused by background JIT compilation. This is how the process looks like: Method f() starts execution in interpreter. After a number of invocations (around 250) the method is scheduled for compilation. The compiler thread works in parallel to the application thread. Meanwhile the method continues execution in interpreter. As soon as … Read more