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.


On Aug 13, 2006, at 12:01 PM, Jim Gallacher (JIRA) wrote:

Memory leak apache.table()

                 Key: MODPYTHON-184
             Project: mod_python
          Issue Type: Bug
          Components: core
    Affects Versions: 3.2.10, 3.3
            Reporter: Jim Gallacher
         Assigned To: Jim Gallacher

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