What are the problems caused by stack overflow errors?

Asked 2 years ago, Updated 2 years ago, 100 views

No matter how much I look for information about stack overflow errors, there is no clear answer. Java documents show that the error java.lang.StackOverflowError is "application says that the recursion depth is so deep that it occurs when a stack overflow occurs, and there are two questions here.

Should I think that the stack didn't write anything on the heap when Java caused a stack overflow error?

java jvm stackoverflow

2022-09-22 22:26

1 Answers

I think you're thinking that stack overflows are like buffer overflows that write to memory not yet allocated in the default program and damage other memory. It's not like that at all.

The JVM allocates memory to each stack in each thread. And if the memory is full in an attempt to call the method, the JVM generates an error. It can also cause memory corruption, as it attempts to write to the nth index of an array of size N. And the stack can't be used on the heap.

A stack overflow error means that there is no more memory available.


2022-09-22 22:26

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.