the official way of killing a b2World?

what is the "official" way of "killing" a b2World?
is setting the variable that holds the b2World to "null" and all the variables that are used in the box2d world to null enough? of course, this also means stopping the "b2World.Step" function from being called... as well as stopping all other functions that have something to do with the box2D world from being called..
Code:
// this is just an example...

theWorld =  null;

// other variables
bodyOne = null;
bodyTwo = null
bodyThree = null;
bodyFour = null;
bodyFive = null;

jointOne = null;
jointTwo = null
jointThree = null;
jointFour = null;
jointFive = null;

timeStep = null;
ratio = null;
// etc...


what is a surefire way to make sure that box2D has been killed and is out of memory?
You must remove all references, AND all events you made referencing stuff. You can use weak reference dictionaries to determine that the world is well and truly garbage collected.

Note that some residual memory usage will remain - some things in Box2D are allocated statically.
Just a warning: I recall reading somewhere that if a chunk of memory marked for garbage collection is larger than a certain size, Flash wont actually delete it.
So is that why there is the bitmapdata.dispose command?!
BorisTheBrave wrote:
You must remove all references, AND all events you made referencing stuff. You can use weak reference dictionaries to determine that the world is well and truly garbage collected.

Note that some residual memory usage will remain - some things in Box2D are allocated statically.


ok got that...

is there a similar method in box2d like..

Code:
while(theMC.numChildren > 0)
{
theMC.removeChild(theMC.getChildAt(0));
}

// maybe box2d would be something like... ?
while(theWorld.bodies > 0)
{
theWorld.removeBody(theWorld.getBodyAt(0));
}
Yes. Something like:
Code:
var body:b2Body;
while(body = world.GetBodyList()) world.DestroyBody(body);


should empty the world of all bodies, joints, fixtures and shapes, which *may* help the garbage collector.

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