cpSpaceReindexShape leaking memory

Discuss any Chipmunk bugs here.
Post Reply
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceReindexShape leaking memory

Post by slembcke »

Hmm. Not sure why that would cause a memory leak off the top of my head. I'm on vacation this week, but left myself a TODO note to check it out when I get back.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceReindexShape leaking memory

Post by slembcke »

Aha. So you are correct. So there are two trees, one for static shapes and one for dynamic ones. The trees are supposed to be sharing the dynamic trees pool of internal data structures, but it looks like when reindexing static objects it's creating a second unshared pool for the static tree. Looks like it shouldn't be too hard to fix.

The buffers are tracked, so at least it would free that memory when the space is freed. For a long running game that reindexed a lot of objects, it could waste a few megabytes of RAM though.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: cpSpaceReindexShape leaking memory

Post by slembcke »

Hah. So even worse than I thought, but very easy to fix. The fix is in the GitHub repository.

It was adding objects from the dynamic tree's pool to the static tree's pool and then NEVER USING THEM AGAIN. Oops. Hehe.
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 6 guests