Question about internal memory allocation

AlexSilverman
Posts: 141
Joined: Mon Jul 02, 2007 5:12 pm

Question about internal memory allocation

Post by AlexSilverman »

Hello,

I'm trying to track down some potential memory leaks, and I have a question about the internal memory allocator that Bullet uses, and more specifically the deallocation schedule.

Our project is a set of smaller games, and as such, we create our subsystems, physics included, when the application is run initially, and then we alter the simulation (add/remove objects, change gravity, etc...) as the games are begun and ended. The actual simulation never gets completely cleaned up and destroyed until the user completely exits the application. Is it possible to ask Bullet to free whatever memory it has allocated to date, such as when there are no objects being simulated (in between games for example)? This would make it easier to determine whether or not we are actually leaking memory, or whether we're seeing the result of Bullet having allocated memory that wasn't freed yet.

If no such method of voluntary deallocation exists, is it possible to dynamically see how much Bullet has allocated so far?

Thanks for any information.

- Alex
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Question about internal memory allocation

Post by Erwin Coumans »

AlexSilverman wrote:Hello,

If no such method of voluntary deallocation exists, is it possible to dynamically see how much Bullet has allocated so far?

- Alex
The memory allocation is improving, and goal for Bullet 2.64 is to have ALL memory allocations to go through the btAlignedAlloc and btAlignedFree. Also, the user can provide their btStackAllocator/btPoolAllocators during construction.

So overriding the btAlignedAlloc and btAlignedFree would give you all information you need, using upcoming version,
Thanks,
Erwin