[mod_python] strange util.FieldStorage() behavior

Neo Eureka neo at https.ru
Wed May 28 15:43:38 EST 2003

  I also suspect some memory leakage caused by mod_python3. I do not
have time to investigate what and where is going on. I use mod_python
with much more complicated code (internet shop, for example), and I
saw constant memory growth. Though it's small, as compared to the
total memory apache2 + mod_python3 take, that gives rise to somewhat
bad feeling. :)

> 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
> http-servers
> ------- memwatch.pl
> while(1)
> {
>   open(OUTPUT, "ps -C httpd -o \"size= pid=\" |") or die "error: $!\n";
>   while(<OUTPUT>)
>   {
>     chomp();
>     my($first, $second) = split();
>     my($sec, $min, $hour) = localtime(time);
>     print "$hour:$min:$sec ", $first, "\t(", $second, ")\n";
>   }
>   sleep(1);
> }
> -------

> 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
> (abovementioned)

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

Neo Eureka / mailto:neo at https.ru

More information about the Mod_python mailing list