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 "Harold Ship (JIRA)" <ji...@apache.org> on 2006/06/30 08:58:30 UTC

[jira] Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

    [ http://issues.apache.org/jira/browse/MODPYTHON-172?page=comments#action_12418577 ] 

Harold Ship commented on MODPYTHON-172:
---------------------------------------

I've been able to reproduce the problem with "mod_python.publisher".

Using:
Windows 2000 Professional
apache 2.0.54
python 2.3.5
mod_python 3.1.3

the following script:
#foo.py
def bar(req):
    a=req.form.getfirst('a')
    req.write('a=%s'%str(a))
    req.write('Ok')

repeatedly sending requests to <addr>/foo/bar?a=b causes memory to rise continuously. removing the querystring does not. I used task manager to measure memory.

I've also found that the following change to util.py corrects this behaviour:

old util.py:
parse_qs = _apache.parse_qs
parse_qsl = _apache.parse_qsl


workaround util.py:
parse_qs = _apache.parse_qs
#parse_qsl = _apache.parse_qsl
from cgi import parse_qsl


> Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55
> --------------------------------------------------------------------------
>
>          Key: MODPYTHON-172
>          URL: http://issues.apache.org/jira/browse/MODPYTHON-172
>      Project: mod_python
>         Type: Bug

>   Components: core
>     Versions: 3.2.8
>  Environment: Win32 XP  SP1 / SP2
> Apache 2.0.55  installed from binary (.MSI)
> Python 2.4.2  or  2.4.3    installed from binary from www.python.org    
>     Reporter: Laurent Blanquet

>
> I encounter memory leaks [~ 16 K per request) using the configuration described below.
> =============================
> Python configuration from Httpd.conf:
> =============================
> Alias /python/ "d:/python24/B2B/"      
> <Directory "d:/python24/B2B">
>         AddHandler mod_python .py                  
>         PythonHandler pyHandlerHTTP                  
>         PythonDebug On                             
> </Directory>                                       
> =============================
> Test handler -  pyHandlerHTTP.py :
> =============================
> import mod_python
> from mod_python import util
> def handler(req):
>       #Removing this line solves the problem.
>       F=util.FieldStorage( req )   
>       return mod_python.apache.OK
> =============================
> HTTP Request (dump using TCPWATCH):
> =============================
> POST http://localhost:80/python/Alertes.py HTTP/1.0
> Content-Type: multipart/form-data; boundary=--------061006144341906
> Content-Length: 209
> Proxy-Connection: keep-alive
> Host: www.tx2-localhost
> Accept: text/html, */*
> User-Agent: Mozilla/3.0 (compatible; Indy Library)
> Proxy-Authorization: Basic Og==
>  
> ----------061006144341906
> Content-Disposition: form-data; name="TYPE"
>  
> LAST_ALERTS
> ----------061006144341906
> Content-Disposition: form-data; name="FILEAGE"
>  
> 180
>  
> ----------061006144341906

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


Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

Posted by Harold Ship <ha...@giant-steps-networks.com>.
Are the memory leaks with the patch still 16K per request?

<snip>

> 
> And I always see some memory leaks after having installed the patch :
> 



Re: [jira] Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

Posted by Laurent Blanquet <lb...@b2btechno.net>.
Hello,

my configuration is always :

>  Environment: Win32 XP  SP1 / SP2
> Apache 2.0.55  installed from binary (.MSI)
> Python 2.4.2  or  2.4.3    installed from binary from www.python.org

I've tested with Handler :

> =============================
> Test handler -  pyHandlerHTTP.py :
> =============================
 import mod_python
from mod_python import util
def handler(req):
       #Removing this line solves the problem.
       F=util.FieldStorage( req )
       return mod_python.apache.OK

And I always see some memory leaks after having installed the patch :

> old util.py:
> parse_qs = _apache.parse_qs
> parse_qsl = _apache.parse_qsl
>
>
> workaround util.py:
> parse_qs = _apache.parse_qs
> #parse_qsl = _apache.parse_qsl
> from cgi import parse_qsl
>

Laurent.

--

----- Original Message ----- 
From: "Harold Ship (JIRA)" <ji...@apache.org>
To: <py...@httpd.apache.org>
Sent: Friday, June 30, 2006 8:58 AM
Subject: [jira] Commented: (MODPYTHON-172) Memory leak with
util.fieldstorage using mod_python 3.2.8 on apache 2.0.55


>     [
http://issues.apache.org/jira/browse/MODPYTHON-172?page=comments#action_12418577 ]
>
> Harold Ship commented on MODPYTHON-172:
> ---------------------------------------
>
> I've been able to reproduce the problem with "mod_python.publisher".
>
> Using:
> Windows 2000 Professional
> apache 2.0.54
> python 2.3.5
> mod_python 3.1.3
>
> the following script:
> #foo.py
> def bar(req):
>     a=req.form.getfirst('a')
>     req.write('a=%s'%str(a))
>     req.write('Ok')
>
> repeatedly sending requests to <addr>/foo/bar?a=b causes memory to rise
continuously. removing the querystring does not. I used task manager to
measure memory.
>
> I've also found that the following change to util.py corrects this
behaviour:
>
> old util.py:
> parse_qs = _apache.parse_qs
> parse_qsl = _apache.parse_qsl
>
>
> workaround util.py:
> parse_qs = _apache.parse_qs
> #parse_qsl = _apache.parse_qsl
> from cgi import parse_qsl
>
>
> > Memory leak with util.fieldstorage using mod_python 3.2.8 on apache
2.0.55
>
> --------------------------------------------------------------------------
> >
> >          Key: MODPYTHON-172
> >          URL: http://issues.apache.org/jira/browse/MODPYTHON-172
> >      Project: mod_python
> >         Type: Bug
>
> >   Components: core
> >     Versions: 3.2.8
> >  Environment: Win32 XP  SP1 / SP2
> > Apache 2.0.55  installed from binary (.MSI)
> > Python 2.4.2  or  2.4.3    installed from binary from www.python.org
> >     Reporter: Laurent Blanquet
>
> >
> > I encounter memory leaks [~ 16 K per request) using the configuration
described below.
> > =============================
> > Python configuration from Httpd.conf:
> > =============================
> > Alias /python/ "d:/python24/B2B/"
> > <Directory "d:/python24/B2B">
> >         AddHandler mod_python .py
> >         PythonHandler pyHandlerHTTP
> >         PythonDebug On
> > </Directory>
> > =============================
> > Test handler -  pyHandlerHTTP.py :
> > =============================
> > import mod_python
> > from mod_python import util
> > def handler(req):
> >       #Removing this line solves the problem.
> >       F=util.FieldStorage( req )
> >       return mod_python.apache.OK
> > =============================
> > HTTP Request (dump using TCPWATCH):
> > =============================
> > POST http://localhost:80/python/Alertes.py HTTP/1.0
> > Content-Type: multipart/form-data; boundary=--------061006144341906
> > Content-Length: 209
> > Proxy-Connection: keep-alive
> > Host: www.tx2-localhost
> > Accept: text/html, */*
> > User-Agent: Mozilla/3.0 (compatible; Indy Library)
> > Proxy-Authorization: Basic Og==
> >
> > ----------061006144341906
> > Content-Disposition: form-data; name="TYPE"
> >
> > LAST_ALERTS
> > ----------061006144341906
> > Content-Disposition: form-data; name="FILEAGE"
> >
> > 180
> >
> > ----------061006144341906
>
> -- 
> 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
>
>


Re: Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

Posted by Harold Ship <ha...@giant-steps-networks.com>.
Hi Nicolas

Howcome I didn't see this post in JIRA? I added my comment there. I also didn't
get email. I just found it in Google.

Anyway, I have an application that was started over a year ago with 3.1.3. We 
switched to 3.2.8 because we had a requirement to upload files and there was a
problem that was fixed in that version.

I observed a memory leak in our application under 3.2.8, and found MODPYTHON-172
on Google. I ran the test program in my first comment on 3.2.8, then tried going
back to 3.1.3 to see if the leak was there too.

This leak seems to be in both 3.1.3 and 3.2.8.

I have added another comment regarding _apachemodule.c, which I include below.

Thanks for your help,
Harold



### ============ Begin Code ==============
Excuse me if this is a dumb question, but I don't know anything about the
Python-C interface.

Is it possible that the code in line 319 of _apachemodule.c (from 3.2.8) is the
problem?

The code is:

            if (key && val)
                PyList_Append(pairs, Py_BuildValue("(O,O)", key, val));

Does the object returned by Py_BuildValue() need to be dereferenced?
Something like:

            if (key && val) {
                PyObject * list_elem = Py_BuildValue("(O,O)", key, val);
                if (list_elem)
                    PyList_Append(pairs, list_elem);
                Py_XDECREF(list_elem);
            }

========================================




Re: [jira] Commented: (MODPYTHON-172) Memory leak with util.fieldstorage using mod_python 3.2.8 on apache 2.0.55

Posted by Nicolas Lehuen <ni...@lehuen.com>.
Hi,

The subject of this thread is about mod_python 3.2.8, yet you report using
mod_python 3.1.3. Which version have you detected the memory leak in ? There
are a bunch of leaks that have been fixed since 3.1.3...

Regards,

Nicolas

2006/6/30, Harold Ship (JIRA) <ji...@apache.org>:
>
>     [
> http://issues.apache.org/jira/browse/MODPYTHON-172?page=comments#action_12418577]
>
> Harold Ship commented on MODPYTHON-172:
> ---------------------------------------
>
> I've been able to reproduce the problem with "mod_python.publisher".
>
> Using:
> Windows 2000 Professional
> apache 2.0.54
> python 2.3.5
> mod_python 3.1.3
>
> the following script:
> #foo.py
> def bar(req):
>     a=req.form.getfirst('a')
>     req.write('a=%s'%str(a))
>     req.write('Ok')
>
> repeatedly sending requests to <addr>/foo/bar?a=b causes memory to rise
> continuously. removing the querystring does not. I used task manager to
> measure memory.
>
> I've also found that the following change to util.py corrects this
> behaviour:
>
> old util.py:
> parse_qs = _apache.parse_qs
> parse_qsl = _apache.parse_qsl
>
>
> workaround util.py:
> parse_qs = _apache.parse_qs
> #parse_qsl = _apache.parse_qsl
> from cgi import parse_qsl
>
>
> > Memory leak with util.fieldstorage using mod_python 3.2.8 on apache
> 2.0.55
> >
> --------------------------------------------------------------------------
> >
> >          Key: MODPYTHON-172
> >          URL: http://issues.apache.org/jira/browse/MODPYTHON-172
> >      Project: mod_python
> >         Type: Bug
>
> >   Components: core
> >     Versions: 3.2.8
> >  Environment: Win32 XP  SP1 / SP2
> > Apache 2.0.55  installed from binary (.MSI)
> > Python 2.4.2  or  2.4.3    installed from binary from www.python.org
> >     Reporter: Laurent Blanquet
>
> >
> > I encounter memory leaks [~ 16 K per request) using the configuration
> described below.
> > =============================
> > Python configuration from Httpd.conf:
> > =============================
> > Alias /python/ "d:/python24/B2B/"
> > <Directory "d:/python24/B2B">
> >         AddHandler mod_python .py
> >         PythonHandler pyHandlerHTTP
> >         PythonDebug On
> > </Directory>
> > =============================
> > Test handler -  pyHandlerHTTP.py :
> > =============================
> > import mod_python
> > from mod_python import util
> > def handler(req):
> >       #Removing this line solves the problem.
> >       F=util.FieldStorage( req )
> >       return mod_python.apache.OK
> > =============================
> > HTTP Request (dump using TCPWATCH):
> > =============================
> > POST http://localhost:80/python/Alertes.py HTTP/1.0
> > Content-Type: multipart/form-data; boundary=--------061006144341906
> > Content-Length: 209
> > Proxy-Connection: keep-alive
> > Host: www.tx2-localhost
> > Accept: text/html, */*
> > User-Agent: Mozilla/3.0 (compatible; Indy Library)
> > Proxy-Authorization: Basic Og==
> >
> > ----------061006144341906
> > Content-Disposition: form-data; name="TYPE"
> >
> > LAST_ALERTS
> > ----------061006144341906
> > Content-Disposition: form-data; name="FILEAGE"
> >
> > 180
> >
> > ----------061006144341906
>
> --
> 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
>
>