[Twisted-Python] Resource instanciated and never destroyed ?

Jp Calderone exarkun at divmod.com
Tue Sep 20 17:45:22 EDT 2005

On Tue, 20 Sep 2005 18:37:40 +0000 (UTC), Anand <web at anand-fr.net> wrote:
>I'm using twisted+web (2.0.1) + Nevow (0.4.1) for building a web application.
>My web application is inside a "Realm" for handling user authentication.
>When an url is requested for a logged in user, this is handled by a resource
>called "LoggedIn", which is a nevow rend.Page subclass.
>LoggedIn redefines the locateChildMethod.
>That method instanciates and returns a resource object , which can be of any
>specific class which I have defined. My resource classes are subclasses of
>I've noticed, putting traces in __init__ and __del__ methods of my resource
>classes, that resource objects which are instanciated are never destroyed.
>As as consequences, the python process ends up eating up a lot of memory.
>I guess I might do something the wrong way.
>I would like to know how resource object can be automatically destroyed after a
>page has been rendered by Nevow + twisted web.
>Thank you for your help

  Instrumenting object lifetime using __del__ alters behavior.  Adding a __del__ method is not a valid way to determine the end of an object's lifetime.

  Nevow 0.4.1 had an egregious Page leak which has since been fixed.  You can test to see if this is the leak you are experiencing by finding all occurrences of adaption which use the callable interface form and which pass "persist=True" and removing the persist parameter.  You could also try switching to a newer version of Nevow, though there is no release of such a thing.

  There is a mailing list dedicated to Twisted Web (<http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-web>) to which I have copied this response.  Please continue this thread there.


More information about the Twisted-Python mailing list