Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^6: Memory leak detection

by Corion (Patriarch)
on Sep 11, 2014 at 07:24 UTC ( [id://1100259]=note: print w/replies, xml ) Need Help??


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

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.

Replies are listed 'Best First'.
Re^7: Memory leak detection
by andal (Hermit) on Sep 11, 2014 at 12:20 UTC

    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 :)

Re^7: Memory leak detection
by runnerup (Novice) on Sep 12, 2014 at 14:48 UTC
    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://1100259]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (3)
As of 2024-04-25 14:22 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found