Bill Moseley wrote:
What are some good methods for tracking down memory leaks?  I used
Devel::Cycle on $c in handle_request() to find one leak.  But, I
suspect I've got a circular reference elsewhere still by the size of
my processes after a while.  (Processes start out showing 70MB and end
up at 140MB rss -- which includes shared memory, of course).
Devel::Leak saved me several times over, but I did need to build a debugging Perl to see the contents. When I did that, most of the leaks I was responsible for were easy to find and fix. I just used NoteSV/CheckSV in the loop, to pick up anything left from a previous iteration. In the end I still found DBI and some DBDs were responsible for most of my missing memory, and upgrading them took away of lot of issues.

All the best
Stuart
--
Stuart Watt
ARM Product Developer
Information Balance
I'm also curious about seeing an increase in "rss" memory in a
very simple Catalyst application.  Could be my testing, or 5.10.0 on
this machine.

$ perl rssmem.pl
Start Rss : 7444
After one request Rss : 9592
Request 1000:  Rss: 9636
Request 2000:  Rss: 9696
Request 3000:  Rss: 9756
Request 4000:  Rss: 9816
Request 5000:  Rss: 9880

It's not that significant, and I think I restart my processes after 1000
requests.

$ cat rssmem.pl
use strict;
use warnings;
use HTTP::Request::AsCGI;
use Catalyst::Utils;
use Linux::Smaps;
my $smap = Linux::Smaps->new( $$ );
App->setup;

print 'Start Rss : ', $smap->rss, "\n";
my $r = make_request();

my $before = $smap->all;
$smap->update;
print 'After one request Rss : ', $smap->rss, "\n";

for ( 1 .. 5000 ) {
    make_request();
    next if $_ % 1000;

    $smap->update;
    print "Request $_:  Rss: " . $smap->rss,"\n";
}


sub make_request {
    my $request = Catalyst::Utils::request( '/ping' );
    my $cgi     = HTTP::Request::AsCGI->new( $request, %ENV )->setup;

    # Uncomment and no gain in rss.
    #return;

    App->handle_request;

    return $cgi->restore->response;
}


package App;
use strict;
use warnings;
use Catalyst;

sub ping : Local {
    my ( $self, $c ) = @_;
    $c->res->body( 'ping' );
}


















_______________________________________________
List: [email protected]
Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
Searchable archive: http://www.mail-archive.com/[email protected]/
Dev site: http://dev.catalyst.perl.org/

Reply via email to