Cleaning up Collision Systems

I’m going over the rewrites for the last chapter of my Panda3D book, which includes stuff on garbage collection. One of the technical editors brought up a point on cleaning collision systems that I could use confirmation on.

Here’s the situation: There’s a custom class that creates a collision traverser and adds colliders to it. The tech editor mentioned that to fully clean up the colliders, they have to removed from the traverser with the clearColliders and clearRecord method, and also from the handlers with the clearColliders method as well. I have no doubt that the tech editor is correct about this.

My question is if the following is true: When the custom class is removed (which I know is happening), this releases the reference to the traverser and handler, which results in the traverser being removed. With the traverser gone, the handler is no longer tied down and will be removed as well. Once both the traverser and handler have been removed, the colliders will be removed as well.

Does that chain-reaction garbage collection work, or am I leaving a dangling collision system floating in memory?

There is a panda book coming?


Your analysis is correct. If you are dropping the traverser and its handlers, there’s no need to explicitly disassociate them from each other. They’ll clean themselves up.

No need to explicitly remove colliders in this case, either.


This is one of the things I love about Panda. So many other python implementations for 3d engines don’t work as seemlessly with Python’s garbage collection.