Bullet on iPhone too much memory

User avatar
sio2interactive
Posts: 31
Joined: Tue Jul 29, 2008 10:26 am

Bullet on iPhone too much memory

Post by sio2interactive »

That's the code that Im using:

Code: Select all

...
...
		btVector3 world_min( -1000, -1000, -500 );
		btVector3 world_max(  1000,  1000,  500 );
		
		config 	 = new btDefaultCollisionConfiguration();
		dispatcher = new btCollisionDispatcher( config );
		cache		 = new btAxisSweep3( world_min, world_max );
		solver 	 = new btSequentialImpulseConstraintSolver();
		
		world      = new btDiscreteDynamicsWorld( dispatcher,	
														cache,
														solver,
														config );
		
		// gravity on earth = 9.80665 m / s2
		world->setGravity( btVector3( 0.0, 0.0, -9.80665f ) );
...
...

And this simple initialization take 42 Meg on the iPhone, here's a screenshot from instruments (leaks template).

Image

Is there any way to reduce the amount of memory use? Especially that on iPhone your app. overall memory shouldn't be more than around 64 meg... this take almost everything. Is there any way to reduce that amount at the cost of less precision or something. Cuz this is way to high and not acceptable...
User avatar
Erwin Coumans
Site Admin
Posts: 4221
Joined: Sun Jun 26, 2005 6:43 pm
Location: California, USA

Re: Bullet on iPhone too much memory

Post by Erwin Coumans »

Try reducing DEFAULT_MAX_OVERLAPPING_PAIRS from 65536 to 6000 (10 times smaller), it should reduce the memory considerably.

sizeof(btPersistentManifold) = 672, so this would reduce from 40Mb to 4Mb.

If necessary, we can add some logic that only allocates manifolds (contact storage) for active (non-sleeping) objects.
Hope this helps,
Erwin
User avatar
sio2interactive
Posts: 31
Joined: Tue Jul 29, 2008 10:26 am

Re: Bullet on iPhone too much memory

Post by sio2interactive »

Dude! tks so much! that totally does the trick... continue your good work.


Cheers!
User avatar
sio2interactive
Posts: 31
Joined: Tue Jul 29, 2008 10:26 am

Re: Bullet on iPhone too much memory

Post by sio2interactive »

Ok I was happy for a moment now I got this crash:


Thread 0:
0 <myappname> 0x00070280 dyld_stub___gtsf2vfp + 4
1 <myappname> 0x000436ce btOptimizedBvh::quantize(unsigned short*, btVector3 const&, int) const (btOptimizedBvh.h:355)
2 <myappname> 0x000452f6 btOptimizedBvh::mergeInternalNodeAabb(int, btVector3 const&, btVector3 const&) (btOptimizedBvh.h:262)
3 <myappname> 0x0004467c btOptimizedBvh::buildTree(int, int) (btOptimizedBvh.cpp:491)
4 <myappname> 0x00044830 btOptimizedBvh::build(btStridingMeshInterface*, bool, btVector3 const&, btVector3 const&) (btOptimizedBvh.cpp:184)
5 <myappname> 0x000569dc btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface*, bool, bool) (btBvhTriangleMeshShape.cpp:39)
6 <myappname> 0x00056a2e btBvhTriangleMeshShape::btBvhTriangleMeshShape(btStridingMeshInterface*, bool, bool) (btBvhTriangleMeshShape.cpp:23)


Erwin, is this related by the previous changes that you suggest me?

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

Re: Bullet on iPhone too much memory

Post by Erwin Coumans »

The btBvhTriangleMeshShape might not be initialized properly.

Do you have more detailed information, can you run the application in the debugger, and see which assert is firing?
Thanks,
Erwin
User avatar
sio2interactive
Posts: 31
Joined: Tue Jul 29, 2008 10:26 am

Re: Bullet on iPhone too much memory

Post by sio2interactive »

Allright Bullet was not in fault... tks for the quick reply ;)

Cheers!