Hi!
I am using a little older version of jBox2D (the build available from www.jbox2d.org, IIRC, not the SVN), and I am implementing pooling for some objects that are created during each frame. I cannot use the newer version that apparently has built in support for object stacks, since I need the engine to work on J2ME and thus cannot use generics.
Anyway, I have implementing pooling for ContactConstraint objects but the engine seems to become unstable after a while when using pooling for these. The more objects I preallocate in the pool (and thus the longer it takes for the engine to return to the first object of the pool) the longer the engine stays stable. Apparently ContactConstraints are created in the ContactSolver constructor, and ContactSolvers are created in the Island.solve() function which, in turn, is run for every body in World.solve(). (I am not using continous collision detection, so you can ignore the TOI stuff).
For how long does the engine need these ContactConstraint objects? When does it release the references? I'm confused since the engine does not seem to store the ContactSolver objects in between time steps, so I thing it should not need the ContactConstraint objects for more than a single time step at a time.
So in a nutshell, I would need to mark the pooled ContactConstraint objects as "in use" when they are created, but I don't know at which point it is safe to mark the objects as "free" again. Can you help me with this, thanks!
I am using a little older version of jBox2D (the build available from www.jbox2d.org, IIRC, not the SVN), and I am implementing pooling for some objects that are created during each frame. I cannot use the newer version that apparently has built in support for object stacks, since I need the engine to work on J2ME and thus cannot use generics.
Anyway, I have implementing pooling for ContactConstraint objects but the engine seems to become unstable after a while when using pooling for these. The more objects I preallocate in the pool (and thus the longer it takes for the engine to return to the first object of the pool) the longer the engine stays stable. Apparently ContactConstraints are created in the ContactSolver constructor, and ContactSolvers are created in the Island.solve() function which, in turn, is run for every body in World.solve(). (I am not using continous collision detection, so you can ignore the TOI stuff).
For how long does the engine need these ContactConstraint objects? When does it release the references? I'm confused since the engine does not seem to store the ContactSolver objects in between time steps, so I thing it should not need the ContactConstraint objects for more than a single time step at a time.
So in a nutshell, I would need to mark the pooled ContactConstraint objects as "in use" when they are created, but I don't know at which point it is safe to mark the objects as "free" again. Can you help me with this, thanks!