Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Please explain me this FindRef output

by ghosh123 (Monk)
on Apr 03, 2012 at 15:17 UTC ( #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 and I am calling a callback function from when I Delete a job and the body of the function is defined in . It is like : $menu->add('command' , -label => 'Delete', -command => sub {$self->onMenuDelete(@_)} ); ## Above $self is A 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?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://963263]
Approved by moritz
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (12)
As of 2017-04-25 15:45 GMT
Find Nodes?
    Voting Booth?
    I'm a fool:

    Results (458 votes). Check out past polls.