You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_python-dev@quetz.apache.org by "Nicolas Lehuen (JIRA)" <ji...@apache.org> on 2005/01/18 18:09:18 UTC

[jira] Updated: (MODPYTHON-1) Circular references starting from the request object create a memory leak

     [ http://issues.apache.org/jira/browse/MODPYTHON-1?page=history ]

Nicolas Lehuen updated MODPYTHON-1:
-----------------------------------

    Fix Version: 3.1.4
                     (was: 3.1.3)

> Circular references starting from the request object create a memory leak
> -------------------------------------------------------------------------
>
>          Key: MODPYTHON-1
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-1
>      Project: mod_python
>         Type: Bug
>     Versions: 3.1.3, 2.7.10
>     Reporter: Nicolas Lehuen
>     Assignee: Nicolas Lehuen
>      Fix For: 3.1.4
>  Attachments: garbage_collection.patch, requestobject.c.gz
>
> Hi,
> I'm running Apache 2.0.50, mod_python 3.1.3 with Python 2.3.4 on Windows XP Pro and Windows 2000 server.
> I finally found a source for the memory leaks I have been observing for a while now : if you store an object in the request object that reference directly or indirectly the request object itself, it builds a circular reference. This circular reference does not seem to be garbage collected.
> The test handler : 
> from mod_python import apache
> def handler(req):
>     # req.foobar=req
>     req.content_type='text/html'
>     req.write('OK')
>     return apache.OK
> I used Apache Benchmark :
> ab -c 5 -n 100000 http://localhost/test.py
> With the comment line, everything is OK, I do not see any memory leak.
> If I uncomment the 'req.foobar=req' line, the memory leak shows up. My Apache process normally uses around 20 MB without the comment, and in 30 seconds of running the above handler (comment removed) with the above Apache Benchmark command, it reaches 125 MB !
> Normally, circular reference are collected by the garbage collector of Python, but unfortunately when defining object from C, you have to do a few tricks to support this :
> http://www.python.org/doc/2.3.4/api/supporting-cycle-detection.html
> It seems that this is not done in mod_python, by having a look at requestobject.c.
> I find this quite a big problem, and I don't find any workaround except "Don't reference the request object from anywhere that might be referenced by the request object", which is a pretty big limitation, quite annoying in the application I'm building.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
   http://issues.apache.org/jira/secure/Administrators.jspa
-
If you want more information on JIRA, or have a bug to report see:
   http://www.atlassian.com/software/jira