Mobile Mesh - after removing from Space, never GC'd

Discuss any questions about BEPUphysics or problems encountered.
Post Reply
Crea
Posts: 10
Joined: Tue Feb 24, 2015 10:54 am

Mobile Mesh - after removing from Space, never GC'd

Post by Crea »

Hi there,

I have a procedurally generated outdoor scene, where I am dynamically creating and destroying a number of mobile mesh objects. I have noticed that they don't seem to be garbage collected, despite my removing them from the space, and I am fairly certain I am not retaining any references to them in my own code. I am reasonably certain this is the case, because when I remove the collision geometry altogether, and progress through the scene, memory usage is very stable; Entities and their associated render geometry which is no longer in the scene is definitely being disposed of correctly.

When, however, I add a corresponding mobile mesh to each of my game objects, and perform Space.Remove(mobileMesh) when they are no longer needed, memory usage continues to climb as I move through the world. It looks to me as though Bepu is retaining a reference to them somewhere internally, even though they've been removed.

Is this a known issue, or is it more likely I've missed a reference in my own code? Or is there other work required to dispose of the mobile mesh instances?

Thanks!
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Mobile Mesh - after removing from Space, never GC'd

Post by Norbo »

There does indeed seem to be a nasty bug that is causing pooled collision constraints to keep references to entities under certain conditions. It applies to mobile meshes, compounds, and I believe all the static mesh types.

There's also apparently another separate bug which causing pooling to fail on pair-generated test collidables, leading to garbage.

Neither of these were known, so thanks for the report! Unfortunately, it looks like it's going to take me a little while to track down all the tendrils responsible for these bugs- they're ensconced within the most horribly and needlessly complicated parts of the engine. (Incidentally, my desire to rewrite almost everything is rising quickly...)
Crea
Posts: 10
Joined: Tue Feb 24, 2015 10:54 am

Re: Mobile Mesh - after removing from Space, never GC'd

Post by Crea »

Ah, great, I'm just pleased you've confirmed it, thanks very much for replying. And thanks for the library, it's brilliant :)
Norbo
Site Admin
Posts: 4929
Joined: Tue Jul 04, 2006 4:45 am

Re: Mobile Mesh - after removing from Space, never GC'd

Post by Norbo »

The bugs should now be fixed.
Crea
Posts: 10
Joined: Tue Feb 24, 2015 10:54 am

Re: Mobile Mesh - after removing from Space, never GC'd

Post by Crea »

Brilliant, thank you (and that was quick!).
Post Reply