I use b2WorldObj.DestroyBody(bodyObj) to destroy the body when it is not needed anymore. The body has one fixture attached to it.

Do I need to destroy the fixture before destroying the body? or should I assume that by destroying the body all its fixtures will be automatically destroyed?

Right now, I do not destroy the fixtures explicitly and the game runs fine. But my concern is more about memory leaks. I want to make sure that all the bodies and fixtures that are not used anymore are completely removed from the memory. How can I best achieve this?


| improve this question | | | | |

You could just have read the manual, you know.

Citation from the manual, chapter 7, section 7.2, page 35 :

You can destroy a fixture on the parent body. You may do this to model a breakable object. Otherwise you can just leave the fixture alone and let the body destruction take care of destroying the attached fixtures

| improve this answer | | | | |
  • \$\begingroup\$ I spent some time to search online before asking the question here, but could not find the answer. I guess I had to go straight to the manual. Thanks for answering. \$\endgroup\$ – Navid Ahmadi Nov 16 '14 at 21:49
  • \$\begingroup\$ Always go straight to the manual and if you cannot find anything in the table of contents or in the likely related document sections, then you can search on google & cie and ask a question here if you still can't find the answer. \$\endgroup\$ – Lærne Nov 16 '14 at 21:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.