Closed MrOnlineCoder closed 8 months ago
Does calling JPH::BodyInterface::removeBody() also deletes (frees the memory) of the body itself, or the cleanup is left for my user-code?
No BodyInterface::DestroyBody deletes the body (and releases the reference to the shape).
Do I need to take care of boxShapeResult in any way, or will it be freed automatically?
Your function should be correct as long as the caller of createBoxShape immediately stores the result in a ShapeRefC
3) Does the destruction of the physics system also removes and deletes all rigid bodies that were added to it?
All bodies are automatically cleaned up on destruction.
Thanks for explanations, just the Remove/DestroyBody part was a bit confusing to me.
I added a bit of documentation here: https://jrouwe.github.io/JoltPhysics/index.html#memory-management
Amazing, much clearer now, thanks
Hi! I have a few questions about objects lifecycle (memory allocation/freeing), as I am getting some strange double-free/segfault errors, and I guess maybe I missed something the docs about it :
1) Does calling
JPH::BodyInterface::removeBody()
also deletes (frees the memory) of the body itself, or the cleanup is left for my user-code? 2) As I understand, many of Jolt methods return aJPH::Ref<T>
which from my understading is a some sort of reference-counting smart pointer? Is it okay to have utility methods like this:Do I need to take care of
boxShapeResult
in any way, or will it be freed automatically? 3) Does the destruction of the physics system also removes and deletes all rigid bodies that were added to it?Thanks in advance and big thumbs up for the work - I really enjoy working with the engine!