Leaking HTTP requests (was: RE: [Zope] Leaking Acquisition.Implic itAcquirerWrapper)

Dieter Maurer dieter at handshake.de
Fri May 14 14:28:13 EDT 2004


Jean-Francois.Doyon at CCRS.NRCan.gc.ca wrote at 2004-5-13 15:31 -0400:
>Looks like I'm actually leaking HTTP requests!

I fear I brought in the "leaking HTTP requests" story...

Meanwhile, I understand that whenever you leak AcquisitionWrappers
you are leaking HTTP requests, too. That's because at the
bottom of the acquisition chain is a REQUEST (usually an
HTTPRequest).

While a cycle created by storing an acquisition wrapper
into REQUEST may cause this leakage, it is by far not the only
potential cause.

Yesterday, I found a leak in my DOM wrapper code caused by code like
this:

	class Element(Implicit,...)

	  __children = None
	  def getChildren(self):
	    '''the elements children.'''
	    if self.__children is not None: return self.__children
	    children = self.__children \
	      = NodeList([c.__of__(self) for c in self._proxy.children])

This creates a cycle between acquisition wrappers.
And leaks acquisition wrappers as well as Request objects....


The major clue to solve my problem has been to look for further
high reference counts for classes that are supposed to have
small reference counts. In my case, I found "DOM.Document",
created at a single place. That allowed me to quickly
verify that I indeed leaked "DOM.Document" references (and everything
below) and after I few hours, I found the code above...


-- 
Dieter



More information about the Zope mailing list