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?



1 Answer 1


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

  • \$\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\$ Commented Nov 16, 2014 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
    Commented Nov 16, 2014 at 21:54

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .