Logo 
Search:

Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Recursive Call

  Asked By: Colleen    Date: Nov 11    Category: Java    Views: 796
  

I have a function in my Java program that might been called recursively for more than 100,000 times. But when I run my program, VM raises an java.lang.StackOverflowError after about 1600 call, and when I run my program with -server java command option, it raises the same error after about 4000 recursive call. I can't change this recursivity.

Does have anybody any idea about this problem?

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Brandi Ramirez     Answered On: Nov 11

It seems that this problem is OS-dependent. Take a
look at:
forum.java.sun.com/thread.jsp

 
Answer #2    Answered By: Archie Parker     Answered On: Nov 11

There is the -Xss option to the Sun JVM which sets the per-thread stack size...

 
Answer #3    Answered By: Hamdan Younis     Answered On: Nov 11

Don't you think that this is one VERY DEEP recursion:) Why don't you measure how much data are you passing as parameters when enteing the recursion ... and this 100K times. Then you can see how big your stack will be. But if I have to be honest I'll better change the recursion or find another way to do this.

 
Answer #4    Answered By: Laaibah Malik     Answered On: Nov 11

Well you are right, it's too deep but it is. I have changed my program  and I used a stack instead of using recursion and this solves my problem.

 
Didn't find what you were looking for? Find more on Recursive Call Or get search suggestion and latest updates.




Tagged: