Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Possible Memory Leak?

by davido (Archbishop)
on Apr 26, 2013 at 19:33 UTC ( #1030883=note: print w/ replies, xml ) Need Help??


in reply to Possible Memory Leak?

Perl uses reference counting as its garbage collection technique. When the last reference to a given object falls out of scope, or is explicitly eradicated (as in your call to delete), the object's reference count drops to zero, and Perl is permitted to clean it up. Memory leaks typically occur when reference counts are prevented from dropping to zero, and that usually happens with self-referential or co-referential objects. If $a = \$a, then when $a falls out of scope the reference count cannot drop to zero. This is what Scalar::Util's weaken() is there to address, or object destructors that are written to break known circular cycles.

A more thorough, and community-refined explanation is available in perlref, under the section Circular References.


Dave


Comment on Re: Possible Memory Leak?
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1030883]
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: (9)
As of 2014-12-27 22:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (177 votes), past polls