Bullet on Android, memory leak (fixed)

Post Reply
mzechner
Posts: 1
Joined: Fri Oct 02, 2009 10:18 pm

Bullet on Android, memory leak (fixed)

Post by mzechner »

Hi,

i "ported" c++ Bullet to android (just a custom makefile) and it compiled straight out of the box. I just had to uncomment two #includes (stdlib.h and float.h) and it worked flawlessly. I'm using it for a physics based 3D game and i'm really excited about the possibilities it opens. Granted my scenes are rather simple (static trimesh ~500 triangles, kinematic trimesh objects ~12 tris each, a few sphere and box shapes) but i didn't expect to work that well.

left for further reference (fixed see below)
Despite all the positive things i can tell you i also found a small problem. I wrap bullet via a jni wrapper class in java (android is mostly java based still). Upon level load i create a complete stack of the basic bullet class instances needed (CollisionConfiguration, dispatcher, solver etc. etc. ). Altough correctly released via delete those objects leave big memory leaks allowing me to create that sort of basic setup around 38 times before memory runs out and the application closes. I circumvented the problem by making the java class a singleton pattern. Creating and destroying trimeshes and other collisionshapes works without problems and does not leak (tested via a special android memory debugging tool called ddms). This way it now happily reloaded 10.000 levels and is still doing so :) (massive stress test over night, my htc hero will probably die :p).

The question is wheter this is an android specific problem or wheter bullet is really intended to be used in a singleton fashion. I digged around in the code of the classes responsible for the leaks but couldn't find anything wrong. Everything seems to be freed correctly upon destructor invocation. I did not fully crasp the aligned allocation code used so i'm not 100% positive on the correctness.

if anyone is interested here's the wrapper code i use around bullet for use in my android app http://www.apistudios.com/hosted/marzec/misc/bullet.cpp. I use the latest bullet source release 2.75 as offered in the download section.

Thanks for making bullet the great library it is and keep up the good work!

edit well this is awkward. i didn't save the pointers into the global variables that are later used to release the memory and thus it leaked. haven't worked in c for quiet some time :p (not an excuse really...). So everything works flawlessly!
FuSiON
Posts: 1
Joined: Sun Jul 31, 2005 7:11 am

Re: Bullet on Android, memory leak (fixed)

Post by FuSiON »

WOW, I never thought it would be possible because the G1 and the Hero don't have a real floating point processor. I'm looking forward to the first ragdoll demo :P
IvanIvanSpb
Posts: 1
Joined: Wed Dec 09, 2009 6:30 pm

Re: Bullet on Android, memory leak (fixed)

Post by IvanIvanSpb »

mzechner, could you provide make file for bullet on android?
Post Reply