Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^3: Memory leak detection

by andal (Hermit)
on Sep 08, 2014 at 06:48 UTC ( #1099838=note: print w/replies, xml ) Need Help??


in reply to Re^2: Memory leak detection
in thread Memory leak detection

However, my question is actually how can ARENA COUNTS show 69084 REF-Tie::RefHash::Weak when all the adding all the scalar(keys %HASHS) of all the hashes using Tie::RefHash::Weak, scalar(keys %EACHHASH) added together is much much less than 69084.

That is why they call it "memory leak" :) The "arena" goes through internal perl structures to see which structures are allocated. As long as variable is accessible from the user code, it is "good" structure. The problem comes, when the structure is not accessible from user code. This structure is then "leaked". So, if you have a leak, then you won't be able to see leaked structures from your perl code. Of course in this case your count won't match the count of "arena".

Replies are listed 'Best First'.
Re^4: Memory leak detection
by runnerup (Novice) on Sep 11, 2014 at 02:46 UTC
    Other than cyclic references (which I don't think could exist in my code), do you know what could cause this to happen?
    I would think that if the reference count is 0, that the objects would be deleted.
    What approach should I use to find the problem?
      Other than cyclic references (which I don't think could exist in my code), do you know what could cause this to happen?

      Well, circular references do not have to be direct. There are lots of subtle ways for creating them. That makes finding them very complex at times.

      I don't know about any other reason for perl to keep unused objects around.

        There is a second way for objects not getting released that is not really a cyclic reference: If you have a subroutine that closes over a variable, the value of that variable will not get released. This is especially nasty if you're dealing with lots of callbacks (like in AnyEvent) and don't keep track of which callback closes over which variable.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2022-11-29 04:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?