[ http://issues.apache.org/jira/browse/MODPYTHON-1?page=all ]
     
Graham Dumpleton closed MODPYTHON-1:
------------------------------------


> 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.2.7
>  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
-
For more information on JIRA, see:
   http://www.atlassian.com/software/jira

Reply via email to