there is a section about memory usage and a subroutine is given which can help test for memory leaks which perl "does no overtly report"
 

Joel Wagner reports that calling an undefined subroutine in a module can cause a tight loop that consumes all memory. Here is a way to catch such errors. Define an autoload subroutine

  sub UNIVERSAL::AUTOLOAD {
          my $class = shift;
          warn "$class can't `$UNIVERSAL::AUTOLOAD'!\n";
  }

It will produce a nice error in error_log, giving the line number of the call and the name of the undefined subroutine.

I edited this to get a little more info:

  sub UNIVERSAL::AUTOLOAD {
          my $class = shift;
    my($package,$file,$line) = caller;
          warn "$class can't `$UNIVERSAL::AUTOLOAD'\n\tCaller Info:\n\t$package\n\t$file\n\t$line\n";
    $" = "\n";
    warn @_ , "\n\n";
  }

I was able to clean up a number of errors which seemed as though they were indeed causing leaks.  For example:

$regex = qr'xx?'i;

Causes the following error:

(?i-xsm:xx?) can't `Regexp::DESTROY'
        Caller Info:
        Apache::JProxy
        /usr/local/apachessl/mod_perl/Apache/JProxy.pm
        780

The only solution I found was to not precompile the regex but it would definilty be nice so as to save some time as I repeatedly use numeros patterns which I was precompliling.

 

Another error I found was with the use of LWP:


LWP::UserAgent=HASH(0x5acb10) can't `LWP::UserAgent::DESTROY'
        Caller Info:
        Apache::JProxy
        /usr/local/apache2_mod_perl/mod_perl/Apache/JProxy.pm
        980

I was able to erradicat this error by adding DynaLoader to the @ISA of LWP::UserAgent.

OK not so bad but one error I have been unable erradicat is the following:

Apache=SCALAR(0x84da840) can't `Apache::DESTROY'
        Caller Info:
        main
        /dev/null
        0

I have not found that Apache,pm has a ISA to add dynaloader to and I have not yet trid adding it my self but......any ideas on where this (apparent) leak is comming from?  It adds 4k to a child per request.  On a site with the amount of traffic we have that is death!!!!

 

Thanks in advance!

Jason Z. Leidigh
Project Leader
UOL Internacional
Av.Libertador 1068 - Piso 3
Capital Federal - ( C1112ABN )
Buenos Aires - Argentina
T.E: 0054-11-5777-2446
Fax:      0054-11-5777-2402
www.uol.com.ar
[EMAIL PROTECTED]

Reply via email to