Skip to main content
gamedev.net
🔒 Locked

StackOverflowError in Java =(

Started by ug02070 Oct 27, 2005 at 11:41 AM 5 replies 1k views
Original Post
ug02070
ug02070
Hi, I am not creating a tree (not actaully a tree but the way each object is linked by reference it is a tree in effect) and i was hoping to simply write my object to disk so i can read/write at will. what i thought was to use xmlencoder as an object can be written straight to disk but it doesnt work with a large tree, i get the following Exception in thread "main" java.lang.StackOverflowError at java.lang.Class.privateGetDeclaredMethods(Unknown Source) at java.lang.Class.getMethod0(Unknown Source) at java.lang.Class.getMethod(Unknown Source) ... ... ... does this mean that the depth of my tree is too large? has anyone had any experience of this at all? thanks Danny =)
Optus
Optus
It does indeed mean that, too many recursions overflowed the stack. To increase the stack size pass the parameter -Xss to Java when running your program like this: "java -Xss8m TestClass"

Edit: 8 megabytes is actually quite an unrealistic stack setting, maybe 1mb or 2mb.
okonomiyaki
okonomiyaki
Have you checked through your code? Make sure it's not a bug that creates infinite recursion which will obviously create a stack overflow at some point.

I don't really know Java, but how large of a tree are you talking? It seems like you shouldn't have to manually increase the stack size unless you are doing something pretty big..
ug02070
ug02070
i am doing something pretty big ye =)
ug02070
ug02070
sorry but does anyone have any other ideas? i have tried -Xss200m (out of memory if i go any higher) and am still getting:

Exception in thread "main" java.lang.StackOverflowError
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.reflect.misc.MethodUtil.getMethod(Unknown Source)
at java.beans.ReflectionUtils.findPublicMethod(Unknown Source)
at java.beans.ReflectionUtils.findMethod(Unknown Source)
...
...

what i have is an object which has a link to two other objects of the same type and i have lots of these objects, by linking these objects the way i have i have created a sorted suffix tree and am also able to traverse it by following the links.
thanks
Danny
Joakim_ar
Joakim_ar
Maybe you should try to count the number of objects you have first, and then do the same inside the saving routines and check if this number is bigger, in which case you're having infinite recursion or at least redundant recursion.
ug02070
ug02070
i dont think there is infinite recursion because it workes for smaller data size, its just when i try to process large ones.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.