From a7c67b4d9d2fe34a1264ac22d8888df773a6bd50 Mon Sep 17 00:00:00 2001 From: Erwin Coumans Date: Thu, 30 Mar 2017 13:50:02 -0700 Subject: [PATCH] avoid memory leaks, even if a the python interpreter exits without calling 'disconnect' on all physics servers (register a Py_AtExit function that cleans all up), to avoid memory leaks --- examples/pybullet/pybullet.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/examples/pybullet/pybullet.c b/examples/pybullet/pybullet.c index cc9bda8d0..85416fbfa 100644 --- a/examples/pybullet/pybullet.c +++ b/examples/pybullet/pybullet.c @@ -1,3 +1,4 @@ +#include "vld.h" #include "../SharedMemory/PhysicsClientC_API.h" #include "../SharedMemory/PhysicsDirectC_API.h" #include "../SharedMemory/SharedMemoryInProcessPhysicsC_API.h" @@ -398,6 +399,22 @@ static PyObject* pybullet_disconnectPhysicsServer(PyObject* self, return Py_None; } + +void b3pybulletExitFunc() +{ + int i; + for (i=0;i