Short answer
Each method call pushes a frame onto the fixed-size per-thread JVM stack sized by -Xss, and exceeding that bound is a stack overflow, a distinct condition from running out of heap.
Explanation
OutOfMemoryError signals the shared heap or Metaspace is exhausted, which is a process-wide problem. The practical implication is that you fix StackOverflowError by reducing recursion depth or converting to iteration, not by raising -Xmx.
Common mistakes
- Increasing -Xmx to fix StackOverflowError.
- Not knowing -Xss controls thread stack size.