Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Need Help gettng Devel::Leak working (or Devel::LeakTrace)

by boysenberry (Acolyte)
on Aug 20, 2005 at 18:08 UTC ( #485409=perlquestion: print w/replies, xml ) Need Help??

boysenberry has asked for the wisdom of the Perl Monks concerning the following question:

I'm getting some "Attempt to free unreferenced scalar" errors while using mod_perl and am trying to use Devel::Leak and/or Devel::LeakTrace to find out which scalar references are off.

In the Devel::Leak doc it gives the following as an example:
use Devel::Leak; ... setup code my $count = Devel::Leak::NoteSV($handle); ... code that may leak Devel::Leak::CheckSV($handle);
In the above what would $handle be? I'm using my own PerlHandler in my httpd.conf file.

Replies are listed 'Best First'.
Re: Need Help gettng Devel::Leak working (or Devel::LeakTrace)
by Util (Priest) on Aug 20, 2005 at 19:37 UTC

    $handle is an output parameter; it is just a integer pointing to a block of memory that Devel::Leak::NoteSV is using to store its internal table. The documentation should probably read:

    use Devel::Leak; ... setup code my $handle; my $count = Devel::Leak::NoteSV($handle); ... code that may leak Devel::Leak::CheckSV($handle);

    Also, be aware that most production builds of Perl do not have -DDEBUGGING turned on, and that the Devel::Leak documentation says:

    Note that you need a perl built with -DDEBUGGING for sv_dump() to print anything, but counts are valid in any perl.
    So, if you were expecting Devel::Leak::CheckSV to give you the details of the leaking objects (as I was when I played with it), you may be disappointed. You can use `perl -V | grep DEBUGGING` to check your build.

      That is a problem for me actually. I'm using an OS X box and tried recompiling in the past with little success.

      Is there another way to track down leaked scalars?

      I have been able to get the mod_perl debugger working via
      httpd -X -DPERLDB
      The "Attempt to free unreferenced scalar" errors I get are on apachectl stop or restart.
Re: Need Help gettng Devel::Leak working (or Devel::LeakTrace)
by boysenberry (Acolyte) on Aug 20, 2005 at 22:42 UTC
    Ok so now I have:
    my $this = {}; bless( $this ); my $count = Devel::Leak::NoteSV( $this->{handle} ); ...application ( too much to list ) Devel::Leak::CheckSV($this->{handle});
    And in my error_log I'm getting:
    new 0xa29e18 :
    ...
    new 0x96f61c :
    old (1):
    0
    new 0xa0fe0c :
    ...
    new 0x9fabe4 :
    old (1):
    0
    new 0x9ffe30 :
    ...
    new 0x96f61c :
    old (1):
    0
    new 0xa00e18 :
    ...
    new 0x96f61c :
    old (1):
    0


    What does the old (1): 0 mean?
    Would that be causing the "Attempt to free unreferenced scalar" errors?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://485409]
Approved by davidj
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2023-02-02 17:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (20 votes). Check out past polls.

    Notices?