[IPython-user] question about garbage collection

killian koepsell koepsell@gmail....
Sun Jul 13 02:08:33 CDT 2008


I noted the following behavior in ipython: If you run the following
few lines in ipython, an object is created and destroyed:

In [1]: class C(object):
  ...:     def __del__(self):
  ...:         print 'deleting object...'

In [2]: obj = C()

In [3]: del obj
deleting object...

The same, of course, works if you run theses line within a script that
is called from ipython. If you don't delete the
object at the end of the script, it is available afterwards in
ipython. For some reason, the object destructor doesn't
seem to be called when the object is later deleted. It seems that even
after deleting the object, there is still some
reference to that object around somewhere. Is this the expected/wanted
behavior? Is it possible to force a complete
destruction of the object in order to free the used memory?


More information about the IPython-user mailing list