Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

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
[Discipulus]: my warmest comprehension karlgoethebier ;=(
[Discipulus]: yes LanX.. is so good to be appreciated (I fortunately have a big self estimation that compensate)
[LanX]: you can manipulate a html tree by addressing and replacing so called document objects (DOM) and from my experience the same methods can be used with any XML, though I didn't test all browsers yet
LanX just joking, playing "ego judo"
[marto]: good morning all
[Corion]: Hi marto!
[marto]: the race to the bottom continues, many people lost their job yesterday as a client moves to another outsourcer
[LanX]: brexit or perlxit ?

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (11)
As of 2017-03-23 09:54 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (285 votes). Check out past polls.