[Catalyst] Tracking down memory leaks

Bill Moseley moseley at hank.org
Wed Dec 24 18:05:05 GMT 2008

On Wed, Dec 24, 2008 at 11:47:45AM -0500, Stuart Watt wrote:
> 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.

Which "loop" are you referring to?

perl -V shows -DDEBUGGING=-g

I tried using Devel::Leak but it ended up not very useful.  Perhaps using
it incorrectly.  For example, if I wrap the eval block in
handle_request() like this:

    use Devel::Leak;
    my $handle;
    eval {
        if ($class->debug) {
            my $secs = time - $START || 1;
            my $av = sprintf '%.3f', $COUNT / $secs;
            my $time = localtime time;
            $class->log->info("*** Request $COUNT ($av/s) [$$] [$time] ***");

        my $c = $class->prepare(@arguments);
        $status = $c->finalize;

        use Devel::Cycle;
        #find_cycle( $c );

Then I get a bunch of output like:

new 0xac62a60 : 
new 0xac62a70 : 
new 0xac62a80 : 
new 0xac62a90 : 

By a "bunch" I mean 16,979.  So, I don't quite think I'm doing it
correctly. ;)

Bill Moseley
moseley at hank.org
Sent from my iMutt

More information about the Catalyst mailing list