Stack Overflows from Deep Recursion in Java

Stack overflows from deep recursion in Java?

I guess you could use these parameters

-ss Stacksize to increase the native
stack size or

-oss Stacksize to increase the Java
stack size,

The default native stack size is 128k,
with a minimum value of 1000 bytes.
The default java stack size is 400k,
with a minimum value of 1000 bytes.

http://edocs.bea.com/wls/docs61/faq/java.html#251197

EDIT:

After reading the first comment (Chuck´s), as well as re reading the question and reading another answers, i´d like to clarify that i interpreted the question as just "increase stack size". I didn´t intend to say that you can have infinite stacks, such as in functional programming (a programming paradigm which i´ve only scratched its surface).

Recursive call stack depth

This is my mistake again... the setting for the Java stack is -Xss (the -Xms setting is the starting heap size), sorry. So if you use the JVM Arguments section in the Debugger tab of the launcher, and set something like -Xss5m, you should get further.

In a simple experiment with a recursive function, the default stack allowed me a depth of 227 calls. Using -Xss5m gave me 4020 calls, and -Xss10m gave me 8050 calls. Note that these stack sizes are somewhat less that the Gb sizes you were trying - 5Mb of stack is a lot of calls!

Add-Recursion in Java, why ist the maximum so low?

Each recursive call will allocate a stack frame. Thus, you run out of stack space.



Related Topics



Leave a reply



Submit