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!
Mobile Mesh - after removing from Space, never GC'd
Re: Mobile Mesh - after removing from Space, never GC'd
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...)
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...)
Re: Mobile Mesh - after removing from Space, never GC'd
Ah, great, I'm just pleased you've confirmed it, thanks very much for replying. And thanks for the library, it's brilliant
Re: Mobile Mesh - after removing from Space, never GC'd
The bugs should now be fixed.
Re: Mobile Mesh - after removing from Space, never GC'd
Brilliant, thank you (and that was quick!).