views:

695

answers:

5

I'm using mod perl 1.3.0 with apache 1.3.41 perl version 5.8.6, and the memory size seems to grow about 4k every 3rd or 4th request. The Perl script we are running is simply:

print "Content-type: text/html\n\n";  print "baby";

Yet that apache process just grows and grows when we slam it with apache benchmark. We are hitting it with:

ab -n 100000 -c 1 http://localhost/search/search.cgi &> /dev/null

and we watch as the process size grows from about 4 megabytes to 24 after about 20000 requests.

To answer the question below: We are doing this on redhat enterprise 4.7. Its been singled out as this because we hit a static file, or a straight up cgi request and the memory does not grow. When we use a PerlHandler Apache::Registry or PerlRun, or just point the PerlHandler to some code that is a handler, then they all leak.

Anyone seen anything like this, or know whats going on?

EDIT:

Thanks for the answers guys. I have used Devel::Cycle and found a leak, but the issue here is we have stripped down our code to printing the header and a statement. There is no way the print function in Perl leaks (I hope....). The memory leak section in Practical Modperl I have read, but it deals with coding issues, and again unless there is an issue with Perl's print function it is not the code.

A: 

Can you please post the details of OS that you are working upon?

Also have you tried letting the process go on till it reaches memory limit and you have to restart your server? Basically what I want to know is how have you singled out that it is memory leak with this module only?

Rutesh Makhijani
+2  A: 

Have you taken a look at the excellent Practial mod_perl and its chapter on memory leaks?

innaM
+1  A: 

If possible, run your code with Devel::Cycle. Chances are you have a memory leak someplace in your code, not in mod_perl specifically.

Once you've located the memory leak(s) - there may be several - fix them.

JDrago
+3  A: 

Since you're down to a print statement, are you sure that you are not loading any other modules? There might be a leak in someone else's code that you are loading.

What do you get when you run this:

package My::Handler;

use strict;
use warnings 'all';
use Data::Dumper;

sub handler : method {
  my ($class, $r) = @_;

  print "content-type: text/html\n\n<plaintext>";
  print Dumper( \%INC );
}

1;# return true:
JDrago
A: 

$VAR1 = { 'XSLoader.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/XSLoader.pm',

'mod_perl.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/mod_perl.pm',

'warnings/register.pm' => '/usr/local/lib/perl5/5.8.6/warnings/register.pm',

'Apache/DBI.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/Apache/DBI.pm',

'List/Util.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/List/Util.pm',

'Test.pm' => '/home/jodonnell/fashion_2009//Test.pm',

'Apache/Server.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache/Server.pm',

'warnings.pm' => '/usr/local/lib/perl5/5.8.6/warnings.pm',

'DBI.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/DBI.pm',

'Config.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/Config.pm',

'bytes.pm' => '/usr/local/lib/perl5/5.8.6/bytes.pm',

'Carp.pm' => '/usr/local/lib/perl5/5.8.6/Carp.pm',

'Exporter/Heavy.pm' => '/usr/local/lib/perl5/5.8.6/Exporter/Heavy.pm',

'Scalar/Util.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/Scalar/Util.pm',

'vars.pm' => '/usr/local/lib/perl5/5.8.6/vars.pm',

'Exporter.pm' => '/usr/local/lib/perl5/5.8.6/Exporter.pm',

'strict.pm' => '/usr/local/lib/perl5/5.8.6/strict.pm',

'Apache.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache.pm',

'constant.pm' => '/usr/local/lib/perl5/5.8.6/constant.pm',

'overload.pm' => '/usr/local/lib/perl5/5.8.6/overload.pm',

'AutoLoader.pm' => '/usr/local/lib/perl5/5.8.6/AutoLoader.pm',

'Apache/Constants.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache/Constants.pm',

'Apache/Constants/Exports.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache/Constants/Exports.pm',

'Apache/Connection.pm' => '/usr/local/lib/perl5/site_perl/5.8.6/i686-linux/Apache/Connection.pm',

'DynaLoader.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/DynaLoader.pm', ``'Data/Dumper.pm' => '/usr/local/lib/perl5/5.8.6/i686-linux/Data/Dumper.pm' };

Looks like to me these things are all loaded by apache.

EDIT: sorry cant figure out how to get this list to look right

jacob
Check your httpd.conf. Something is loading Apache::DBI and DBI. Is there other code executing that you are not aware of?
JDrago
Also - please please edit your reply so that the text is on multiple lines.
JDrago
i have checked the http conf pretty thoroughly and tried removing everything unneseccary but i reverted my changes so its not reflected here. I could not figure out how to make it multiple lines, i will try again
jacob