Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re^5: Memory leak detection

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


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

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.

Replies are listed 'Best First'.
Re^6: Memory leak detection
by Corion (Patriarch) on Sep 11, 2014 at 07:24 UTC

    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.

      Strictly speaking this is not a "leak". The variables are still accessible from the code. They will get released when the subroutine goes out of scope. Of course, if one of subroutines references variable that keeps reference to that subroutine, then neither code, nor the variable will be released, but this is circular reference again :)

      Thanks for your reply.
      > If you have a subroutine that closes over a variable, the value of that variable will not get released

      What do you mean by "subroutine that closes over a variable"?

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2022-01-27 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?