Python cleanup on exit

Jacob Kroon jacob.kroon at gmail.com
Fri Mar 10 13:17:57 EST 2006


Hi,

I'm working on a library written in C using GObject, which i
provide python bindings for using pygtk. When I checked the
library for memory leaks using valgrind, I noticed that none
of the objects I created in the script (that is they are global in
the script) were deleted on exit. After some googling I came
to the conslusion that the python interpreter doesn't "cleanup"
after itself on exit, because of shutdown performance.

This means that if I want to check the library for mem leaks I have
to either manually "del myobject1, delmyobject2 ..." at the end
of the scripts, or make sure that all objects get created in a
function scope, so that python will delete them for me when
the interpreter exits the scope.

Is there another way to make python delete objects which were
created in the global scope upon exit ?

                                           Jacob




More information about the Python-list mailing list