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?