[mod_python] strange util.FieldStorage() behavior

Karsten Backhaus kaback at kaback.de
Wed May 28 12:57:54 EST 2003

I'm using mod_python 2.7.8 with apache 1.3.27 under SuSE Linux 8.2

i wrote a simple handler script that only parses its "cgi parameters"
using util.FieldStorage() and returns apache.OK

the script worked fine so far, but everytime the script runs, the memory
used by apache rises a few kbyte.

next i removed the util.FieldStorage() function from the script, with the
result, that the memory usage remains constant.

because of that i searched for an other way to get access to the committed
form parameters and found the mod_python.publisher handler.

i added the publisher handler to my apache config and wrote a file 
"hello.py" with the following content:
""" Publisher example """

def say(req, what="NOTHING"):
    return "I am saying %s" % what

now a request with the url http://localhost/hello/say?what=blahblah
returns the expected "I am saying blahblah

i wrote a script, that calls wget on that url within an endless loop:
------- getit.pl
while(1) {
        system("wget -O test.htm http://localhost/hello/say?what=blah");

next i wrote a verry simple "tool" that monitors memory usage of my
------- memwatch.pl
  open(OUTPUT, "ps -C httpd -o \"size= pid=\" |") or die "error: $!\n";
    my($first, $second) = split();
    my($sec, $min, $hour) = localtime(time);
    print "$hour:$min:$sec ", $first, "\t(", $second, ")\n";

and, the unexpected happens, runnig memwatch.pl while running getit.pl
shows the constant growing memory usage of the httpd processes.

the longer the string after http://localhost/hello/say?what= is, the
more the memory seems to grow each time.

reading the docs, i found, that even mod_python.publisher uses the
functionality of util.FieldStorage(), which i wanted not to use
because of the strange things i figured out during my first test

for me at the moment this looks like a amemory leakage in 
util.FieldStorage. i searched the archive and did not found anything 
regarding that behavior.

so my question is: Am I doing something wrong? 

thanks in advance

More information about the Mod_python mailing list