Driving Demo using Ammo.js

With Ammo, you need to handle garbage collection yourself. Variables you create with ‘new’, such as:
var downRayDir=new Ammo.btVector3(0,0,0);
are not removed automatically by javascript. You need to say:
Ammo.destroy(downRayDir);
as soon as you no longer need the variable.
I also say:
downRayDir=null;
but I lazily never bothered to find out if that is necessary.
I also reuse an Ammo.btVector3 variable in some cases, instead of creating new ones all the time.
You can use Chrome’s task manager to check your memory usage, and make sure it is not growing.
I was also using the Memory tab in Chrome’s Developer Tools, but it has been a while and I do not recall how I was using that.
I hope I am steering you correctly. I am only a tinkerer. Please chime in anybody who knows better.

3 Likes