[ 
http://issues.apache.org/jira/browse/MODPYTHON-184?page=comments#action_12447665
 ] 
            
Alexis Marrero commented on MODPYTHON-184:
------------------------------------------


   [[ Old comment, sent by email on Tue, 15 Aug 2006 15:54:50 -0400 ]]

Jim,

This are my results for the memory leak search in apache.table().

The table object creates a memory pool by using apr_pool_create_ex()  
and destroys the pool using apr_pool_destroy(). I added a line in  
MpTable_New() before "return (PyObject*)t" to destroy the pool and  
ran 1M iterations and I notice that there was no memory leak.   
Therefore the apache functions seems to be working fine.

I couldn't fix the problem but here is a work around. In mod_python/ 
util.py instead of using apache.make_table() use a regular Python  
dictionary.  So the line that looks like:

headers = apache.make_table()

now looks like:

headers = {}

The apache table is basically used a Python dictionary. The only  
functionality that is lost is that apache tables are case  
insensitive, and that can be easily fixed by creating a class in  
Python that inherits from dict type and override the __getitem__ and   
__setitem__ methods.

For the moment I'm going to keep this changes until modpython.org  
release a patch.  I spent quite sometime trying to investigate and  
solve the memory leak problem but the best I was able to do was to  
work around it.

BTW,  apache.table, apache.make_table or _apache.table is only being  
used in mod_python/util.py.


/amn




> Memory leak apache.table()
> --------------------------
>
>                 Key: MODPYTHON-184
>                 URL: http://issues.apache.org/jira/browse/MODPYTHON-184
>             Project: mod_python
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 3.3, 3.2.10
>            Reporter: Jim Gallacher
>         Assigned To: Jim Gallacher
>             Fix For: 3.3
>
>         Attachments: MP184-2006-08-25-grahamd-1.diff
>
>
> There is a memory leak in apache.table().
> from mod_python import apache
> def handler(req):
>     req.content_type = 'text/plain'
>     t = apache.make_table()
>     req.write('ok table:')
>     return apache.OK
> Using mpm-worker with StartServers 2, and 20000 requests results in memory 
> consumption going from 1.2% to 9.3% per process. (ie approx 8k per request)
> This will have an impact on FieldStorage which makes use of 
> apache.make_table(), which is the deprecated name for apache.table()

-- 
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