Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change

Re: Tracking down memory leaks in Perl Devel::Leak

by tilly (Archbishop)
on Mar 26, 2009 at 06:28 UTC ( #753352=note: print w/replies, xml ) Need Help??

in reply to Tracking down memory leaks in Perl Devel::Leak

This leaks one object every time you hit return, then tells you how many scalars there are. (The memory leaks because $bar has a reference to itself, and so its reference count will never reach 0.)
#! /usr/bin/perl -w use strict; use warnings; use Devel::Leak; while(1) { my $count = Devel::Leak::NoteSV(my $foo); print "$count"; <>; my $bar; $bar = \$bar; }

Replies are listed 'Best First'.
Re^2: Tracking down memory leaks in Perl Devel::Leak
by brycen (Monk) on Mar 26, 2009 at 16:51 UTC
    What I can't get working is the extended debugging promised by the Devel::Leak documentation. All I get is a count, and from CheckSV, the cryptic "new 0x5a18b0".
    #! /usr/bin/debugperl -w use strict; use warnings; use Devel::Leak; my $foo; my $countdown = 10; while($countdown--) { my $count = Devel::Leak::NoteSV($foo); print "$count"; <>; my $bar; $bar = \$bar; } my $count = Devel::Leak::CheckSV($foo); print "End $count\n";
    2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 new 0x5a18b0 : End 2610
    Even though I've got a debugging perl from Debian:
    debugperl -V Summary of my perl5 (revision 5 version 8 subversion 8) Characteristic +s of this binary (from libperl): Compile-time options: DEBUGGING MULTIPLICITY PERL_IMPLICIT_CONTEXT PERL_MALLOC_WRAP THREADS_HAVE_PIDS USE_64_BIT_ +ALL USE_64_BIT_INT USE_ITHREADS USE_LARGE_FILES USE_PERLIO USE_REENTRANT_API
    What I can't get working is the sv_dump() mentioned in the Devel::Leak documentation. And when I'm debugging a 100000+ line plus application, that will be crucial.
      That I am unlikely to be able to help you with. I don't have Perl built with debugging.

      At a random guess, you need to both have a debugging perl and you need to have compiled Devel::Leak against it. If you install a debugging Perl and Devel::Leak using apt-get, I would expect that copy of Devel::Leak to not understand that it has access to debugging information.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://753352]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2023-02-07 05:03 GMT
Find Nodes?
    Voting Booth?
    I prefer not to run the latest version of Perl because:

    Results (38 votes). Check out past polls.