We all know StackOverflowError occurs commonly from bad recursive functions causing the heaps of memory to collide. But what if each time you run the function you clear up the memory (set value to null)? Will it allow infinite loop with no error?
Asked
Active
Viewed 26 times
0
-
I did not know that the heaps of memory collide. TIL – Atreys Feb 21 '17 at 01:03
-
according to the answer to Stackoverflow error, the "heap" can collide with the "Stack": http://stackoverflow.com/questions/214741/what-is-a-stackoverflowerror – Goodwin Lu Feb 21 '17 at 01:04
1 Answers
0
We all know StackOverflowError occurs commonly from bad recursive functions causing the heaps of memory to collide.
This is incorrect. Assuming you're talking about Java here, StackOverflowError is thrown when your thread's stack exceeds the configured limit, which is typically at least 256 kB, and no more than a couple of megabytes. It doesn't have to actually collide with the heap -- this concept doesn't really apply in a multithreaded environment.