Help with Memory Leak (iPad)

Official forum for the Chipmunk2D Physics Library.
Post Reply
zacware
Posts: 5
Joined: Sun Sep 27, 2009 5:25 pm
Contact:

Help with Memory Leak (iPad)

Post by zacware »

Running on an iPad, my game quickly crashes with a level 2 memory error (not on the simulator, as the simulator gives it tons of ram)

I stripped out 95% of the code to make a simple example (attached below)

http://web.me.com/zacware/UghArgh.zip

The heart of the issue is somewhere in GameLayer.m

If I let the stripped down sample run 10 or so minutes it will crash too. The memory is displayed at the bottom next to the FPS and it slowly but surely decreases and crashes

The leaks instrument only shows a very small amount of leaks. The allocations table shows a lot of entries for "getunusedbin" that add up to a lot of ram.

Any help is helping me figure out what's eating memory is appreciated.

My alternate plan is to create a pre-existing array of objects and just reuse them once they are off screen or part of a collision, but I would think I should be able to destroy an object and have all of it's memory freed up. I just can't figure out what I'm doing wrong. Ugh!

PS. Several people have pointed out my dealloc method is missing stuff in the sample. I accidentally deleted too much when I made the sample, but in the sample dealloc should never be called since the game loop runs forever.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Help with Memory Leak (iPad)

Post by slembcke »

I recently fixed a nasty memory leak related to post-step callbacks, (which you are using) but the fix hasn't been put out in a release yet.

Grab the latest trunk code and look in the README for instructions for building the static library (you may have to edit the script to adjust the SDK version). You can just drop this in as a replacement for the current Chipmunk 5.3.1 folder you have. It also makes sure all the correct optimization flags are set so you get the best performance.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
zacware
Posts: 5
Joined: Sun Sep 27, 2009 5:25 pm
Contact:

Re: Help with Memory Leak (iPad)

Post by zacware »

Thanks!!!!!! That fixed it! Whew!!!!!! I am so happy to have this fixed
Post Reply

Who is online

Users browsing this forum: No registered users and 19 guests