Leaking HTTP requests (was: RE: [Zope]
LeakingAcquisition.ImplicitAcquirerWrapper)
Brian Lloyd
brian at zope.com
Thu May 13 17:41:11 EDT 2004
Zope.org doesn't use Localizer (or Archetypes - another thing
that has come up in this thread).
In our experience, this sort of thing has almost always turned
out to be a wrapped object ending up in the REQUEST or a wrapped
object holding onto a request for some reason.
I've attached a quick product you can drop in to test that
theory on your own instance (just make a directory
Products/LeakBGone and drop this __init__.py into it and
restart).
If it fixes the leak, we can extend it to do some logging and
try to figure out the root cause. I'll try it out on zope.org
as soon as I'm able.
Brian Lloyd brian at zope.com
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
> -----Original Message-----
> From: zope-bounces+brian=zope.com at zope.org
> [mailto:zope-bounces+brian=zope.com at zope.org]On Behalf Of Stefan H.
> Holek
> Sent: Thursday, May 13, 2004 3:14 PM
> To: Brian Lloyd
> Cc: Jean-Francois.Doyon at CCRS.NRCan.gc.ca; zope at zope.org
> Subject: Re: Leaking HTTP requests (was: RE: [Zope]
> LeakingAcquisition.ImplicitAcquirerWrapper)
>
>
> Does zope.org use Localizer or some type of "global request" patch?
>
> Stefan
>
>
> On Donnerstag, Mai 13, 2004, at 21:42 Europe/Vienna, Brian Lloyd wrote:
>
> > FWIW - zope.org is suffering hugely from this as well, so
> > I'm following this thread eagerly ;)
> --
> The time has come to start talking about whether the emperor is as well
> dressed as we are supposed to think he is. /Pete McBreen/
>
>
> _______________________________________________
> Zope maillist - Zope at zope.org
> http://mail.zope.org/mailman/listinfo/zope
> ** No cross posts or HTML encoding! **
> (Related lists -
> http://mail.zope.org/mailman/listinfo/zope-announce
> http://mail.zope.org/mailman/listinfo/zope-dev )
>
-------------- next part --------------
##############################################################################
#
# Copyright (c) 2003 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE
#
##############################################################################
"""LeakBGone
An experimental monkey-patch product that tries to ensure that no
unexpected objects (especially acquisition-wrapped objects) remain
on the REQUEST object that could cause a circular reference (and
thus a memory leak). It is still bad form to store such objects in
a request, whether this hack works or not ;)
"""
from ZPublisher.HTTPRequest import HTTPRequest
from zLOG import LOG, INFO
def close(self):
"""Replace the standard REQUEST.close method with one that
explicitly wipes out everything and takes no prisoners."""
# If this works ok, next step is to add some logging whenever
# we find a wrapped object, so that we can stub out the cause.
names = self.__dict__.keys()
for name in names:
value = getattr(self, name)
clear = getattr(value, 'clear', None)
if clear is not None and callable(clear):
clear()
setattr(self, name, None)
value = None
def initialize(context):
HTTPRequest.close = close
LOG('LeakBGone', INFO, 'LeakBGone initialized')
More information about the Zope
mailing list