Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Please explain me this FindRef output

by ghosh123 (Monk)
on Apr 03, 2012 at 15:17 UTC ( [id://963263]=perlquestion: print w/replies, xml ) Need Help??

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

Hello Monk, I am using Devel::FindRef to find out memory leak in my program. Please explain me the output so that I get a clue where to look into. Suppose I have two module say A.pm and B.pm. I am calling a callback function from A.pm when I Delete a job and the body of the function is defined in B.pm . It is like :

A.pm $menu->add('command' , -label => 'Delete', -command => sub {$self->onMenuDelete(@_)} ); ## Above $self is A B.pm sub B ::onmenuDelete { my B $self = shift; my $temp = $self->{business} ; $self->jobdisplayobj->deleteElements(); print Devel::FindRef::track \$temp; } The output is :REF(0xb20ba50) [refcount 2] is +- referenced by REF(0xbe1398c) [refcount 1], which is | a temporary on the stack. +- the lexical '$temp' in CODE(0xb20b900) [refcount 4], which is +- the global &A::onMenuDelete. +- the global &B::onMenuDelete.

Please explain me the above output. I guess there are 2 references of $temp, one is the stack which is the $temp variable itself. Where is the other hanging?

Replies are listed 'Best First'.
Re: Please explain me this FindRef output
by Khen1950fx (Canon) on Apr 03, 2012 at 19:21 UTC
    The result is a little too mundane. I prefer Devel::Leak. I'd rather see something like this:
    package B; use strict 'refs'; use warnings; use Devel::Leak; my $count = Devel::Leak::NoteSV($handle); my $self = shift @_; my $temp = $$self{'business'}; print "The count is: $count\n"; my $now = Devel::Leak::CheckSV($handle); # more code here print "The count is now: $now\n";
    The output makes more sense to me.
Re: Please explain me this FindRef output
by Anonymous Monk on Apr 03, 2012 at 21:34 UTC

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (2)
As of 2024-04-25 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found