Search code examples
javaeclipserecursionstack-overflow

Increase the recursive ability of Eclipse


I'm writing a java program in Eclipse, and when I try to use recursion it gives this error:
Exception in thread "main" java.lang.StackOverflowError
I know that people have probably already asked this question, but every response I've found has been to remove recursion. For what I'm trying to do, recursion is a necessity. There's no other option. I know that the recursive limit can be modified in Enthought Canopy (for python) like this:
import sys
sys.setrecursionlimit(10000)
Is there a way to do this for java in Eclipse? Again, removing recursion is not an option.

UPDATE: I figured out the problem (which was an infinite loop), and the code works now.


Solution

  • Take a look at this: What is the maximum depth of the java call stack?

    While it is not exactly a duplicate, it also answers your question by explaining how the limit can be changed.


    Note that Eclipse itself has nothing to do with the limit, it is a Java restriction and can be increased by allocating more space to it.


    As always with such questions one should note that your code is likely to be inefficient, wrong or maybe has a non-recursive alternative. However you said that you are not interested in such solutions, so I just leave it here as a side note.