Java.lang.StackOverflowError

Hi all,

does anybody know why this happens? and what can be done to rectify it?

DP

Where does this happen exactly ?

it doesn’t give a stack trace, so I can’t find out.

What are you doing when it happens?

ive narrowed it down to CollisionDetection.hasCollision(player.getSpatial(), enemy.getSpatial(), rs);



taking that statement out, its fine, putting it back in, goes all haywire.



That error didn’t occur in a two week old jME version.



DP

Or you could be doing more in your game. You could always check out a two week old copy of cvs to check though.

oh no, soz, i didn’t make myself clear at all, I wasn’t saying it was jME’s fault no no nooo, it was me, I just want to know what causes these kind of errors and anything I could do to prevent them. Is there a way of increasing the stack size by any chance?

Are you using my MD2 loader? If you are the controllers can be shared for similarly animating models. They are a ton of memory each. I’m working out the best way to signal sharing, then I’ll try to add a feature for it. Untill then you can always share the KeyframeController’s ArrayList of states yourself.

im using .jme, and there are only 3 animated models on there, 2 zombies and the player. Increasing the memory increases the stack too?

"DarkProphet" wrote:
Is there a way of increasing the stack size by any chance?

From the java documentation of command line parameters to the VM:
-Xssn
Set thread stack size.

If this helps. Stacks are on a per-thread base.

awsome, thx for the info batman, but it didn’t solve the problem:



-Xss50m giving each thread 50 Mb of stack size, yet, i still get the error. Setting to 64 Mb, i get:



java.lang.OutOfMemoryError: unable to create new native thread



So its taking up too much space/thread.



Any more ideas?

Do you have recursive functions? is it endless?



[Edit] fixed spelling

I usually see those when I screw up and have an infinite loop. Ie, it calls too many methods (usually the same one, as is with recursion), and Java can’t deal with that. There’s a ‘method’ stack (I can’t remember the official name of it) that gets data pushed onto it for every method that gets called. When the method call returns, it pops the data back off the stack. You can only go so ‘deep’ with the number of method calls. It’s really pretty far, though.



Your OutOfMemory exception would lead me to believe this is the case – that something is happening to cause an infinite loop.



Basically, what Badmi is getting at.





–K

the hasCollision could get out of hand if your scenegraph has loops in it, for example, nodes whose children are their grandparents. Sounds crazy, but can happen.

I meant an infinite loop that’s not supposed to be infinite and is hence chewing up tons of memory that you don’t mean for it to. :stuck_out_tongue:



Make sure to let us know if you figure it out.


the hasCollision could get out of hand if your scenegraph has loops in it, for example, nodes whose children are their grandparents. Sounds crazy, but can happen.


But wouldn't that mean that it would also crash during rendering as well? going through all the nodes and coming back to the original node? the rendering process would never finish because it would keep looping forever.

DP

That’s possible in the case I mentioned, but it depends on if the given loop traces up or down the tree since Spatials can only have one parent (or at least can only have one parent set in their parent field) but also can be children of multiple nodes.

gotcha, right, would be it safe to say that if I took a single line out of a program and the program started to execute fine, and the line doesn’t change anything in the scenegraph, that the trouble is in this line of code?



I have never done any debugging before, as it was all so straight forward before.



DP

Depends on what that line of code does. LOL… I mean, if it modifies the state of other parts of the code allowing them to do things that end up causing an error, the line of code does expose the error, but is not the resposible party.

ive managed to narrow it down to which type of boundingVolume I am using. With spheres i get the stackOverflowException. With boxes, it seems to run just fine.



DP