stackoverflowerror

R

rajesh.rapaka

Hi,

I am using a recursive function which calls itself 100 to a milliion
times or so. as a result i am getting the "StackOverFlowError". How can
I solve this??? is it because of the JVM. i am using the latest version
of JDK.( I dont remember its number). Kindly help !!

regards,
rajesh.rapaka
 
K

Karel Suikers

rajesh.rapaka schreef:
I am using a recursive function which calls itself 100 to a milliion
times or so. as a result i am getting the "StackOverFlowError". How can
I solve this??? is it because of the JVM. i am using the latest version
of JDK.( I dont remember its number). Kindly help !!

I don't think the JVM is a problem, it's your memory. When you call a
recursive function a million times, it needs huge amounts of memory.
 
T

Thomas Weidenfeller

rajesh.rapaka said:
I am using a recursive function which calls itself 100 to a milliion
times or so.

Rewrite the algorithm or chose another one.

/Thomas
 
R

rajesh.rapaka

yes sometimes i also get the OutOfMemory error. Will both these problem
get solved if i use huge amounts of memory?
Can you suggest any Intelligent ways of using the available memory?
 
R

rajesh.rapaka

Rewrite the algorithm or chose another one

It is a Dicom image file. which contains any number of tags. to read
each tag it has a process. the function - tagReader consists of all
these decoding elements. so tag1 is decoded by tagReader then tag2 and
then tag3 and so on.

tagReader(){

process{

// decoding process

}

if ( not lastTag )
tagReader()

}

in this way it is called recursively. do u think there can be anyother
algorithm for such kind of static thing?

rajesh rapaka
 
G

Gordon Beaton

in this way it is called recursively. do u think there can be
anyother algorithm for such kind of static thing?

If the tags are sequential, there is no need for a recursive
algorithm:

tagReader() {
while (not lastTag) {
process();
}
}

/gordon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,270
Latest member
TopCryptoTwitterChannels_

Latest Threads

Top