Determinism and Jbox2d -- Problematic workaround found!

Hey!

I've read much about the attempt at determinism in Jbox2d, and have found a simple workaround that ALMOST works.

I am working with Processing and Fisica (a jbox2d wrapper), so that adds another degree of separation -- (I'm also not all that versed in changing/compiling Java code, so the potential of adding strictfp to all the classes, and then recompiling both Jbox2d and Fisica is a little daunting).

This is my first version where each run is different [non-deterministic] (click to reset bricks)
Check : http://leifparker.com/_storage/explosive_test/

If you click the applet, it will erase the geometry and set it up exactly as previous, and the result will be entirely different. BUT -- If you reload the webpage, you'll notice that the first iteration is always the same. Thus my idea of just creating a new instance of the World variable -- and it does work!

Clicking will clear all the bricks, and start from scratch with a new World. [deterministic]
Check : http://leifparker.com/_storage/explosive_test_v2/

New problem : I quickly run out of memory. It seems that some part of the World constructor assigns a reference that doesn't get de-referenced when I instantiate a new World. Java's garbage collector isn't cleaning up the old World instance properly.

What can I do? Any ideas?

Thanks in advance,
L
I had this same problem a while ago. The source of the problem turned out to be in DynamicTree.java

There is an instance of Random there that's getting initiated without a seed. I changed it to this:

private final Random rand = new Random(0);

And that fixed all my problems. Just SVN the source and make your own build with that change. There may be a way to get at it through your own code, and thus skipping the hassle of making your own build, but I'm not sure.

Let me know if that helps out.

-Ben
update to 2.1.2! that version should be much more deterministic

Original thread: https://box2d.org/forum/viewtopic.php?t=7285