cpSpaceAddPostStepCallback - memory leak?

Discuss any Chipmunk bugs here.
Post Reply
Peter
Posts: 3
Joined: Mon Aug 23, 2010 7:01 am
Contact:

cpSpaceAddPostStepCallback - memory leak?

Post by Peter »

I've found that calling cpSpaceAddPostStepCallback consumes memory that seems to be never released, even on cpSpaceFree.

For example, in ChipmunkDemo:
Task Manager shows that at LogoSmash it uses ~8600Kb. After switching to Sensors(which uses PostStep callbacks) and waiting about 10 minutes, you'll notice that program uses much more memory. Back to LogoSmash - it is ~31000Kb instead of ~8600Kb.

So, 21 Mb of memory in 10 minutes - is this a bug or am I missing something?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by slembcke »

Confirmed. That's kind of a nasty one too. I was forgetting to free a hash set that got allocated each frame a post step callback was used.

Good catch. I usually check the demo app for memory leaks before releasing, but I guess I missed that one.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
paule
Posts: 2
Joined: Fri Sep 10, 2010 3:02 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by paule »

How do I fix this? It eats up my memory since I need to call it constantly. :(
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by slembcke »

This bug has been fixed in trunk, but it looks like it hasn't made it out into a release yet.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
paule
Posts: 2
Joined: Fri Sep 10, 2010 3:02 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by paule »

Thanks for the information and the fixing :)

Will use the trunk until the release comes out. ;)
mlmcgoogan
Posts: 1
Joined: Tue Sep 14, 2010 2:11 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by mlmcgoogan »

Just ran into the leak myself. Thanks for the fix!

Keep up the awesome work!
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceAddPostStepCallback - memory leak?

Post by slembcke »

So I think this leak may have existed since I implemented the post-step callback feature... Not sure how it went so long without being noticed.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests