Python cleanup on exit

Fredrik Lundh fredrik at pythonware.com
Sat Mar 11 02:57:59 EST 2006


Jacob Kroon wrote:

> 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.

are the objects persistent on a system-wide level ?

if not, what's the problem ?  the operating system will clean them all
out much faster than you can do it yourself.

(the usual way to look for true leaks is to run the relevant code in a
loop.  stuff that's left for the operating system to throw away very
seldom qualifies as "leaks").

</F>






More information about the Python-list mailing list