[Zope] Re: [Zope-dev] Database Cursors and Gargabe collection ?

Dieter Maurer dieter@handshake.de
Mon, 9 Sep 2002 20:36:23 +0200


I do not think, this is a typical "zope-dev" question (development *of* not
*with* Zope).
Rerouted to Zope@zope.org...

Romain Slootmaekers writes:
 > we have a problem using garbage collection to clean up open database 
 > cursors.
 > ...
 > class CursorWrapper:
 > ...
 >      def __del__(self):
 >          self.__cursor.close()
 >          del self.__cursor
 >          print "deleted"
 > 
 > So in theory, the cursor will be closed on GC.
The cyclic garbage collector can not release cycles with
objects that have a custom destructor (i.e. a "__del__" method).

The reference counting garbage collector can (but it cannot release cycles).

Thus, if your cursor wrappers happen to be part of a cycle, they will
not be released. From your code, I did not see a hint that this is the
case, though...


Dieter