Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
There are 3 ways to get a memory leak in a perl program: construct a circular reference (as described by other comments above); find and tickle a bug in perl's reference counting; or find and tickle a bug in some other external non-perl code (such as an XS library).
And those potential bugs in the perl interpreter and XS libraries are IMO the biggest drawback of a reference counting scheme. Circular references in perl are usually easily avoided (you can now even use weakrefs with the standard distribution if you need to) - but when you're writing extensions or modifying the interpreter you need to get the reference count correct in all C/C++ code using perl's data types. This is extremely brittle, when you consider passing subroutine arguments, changes in scope, stuffing data in lexicals, mortal SV*s etc etc. At least, I usually mess it up hard :-)

As far as I understand it, a "real" garbage collector can replace most of this mess with a centralized (but complicated) garbage collection algorithm. at the cost of (usually) not guaranteeing a specific destroy time for objects (perl objects are at the moment guaranteed to be DESTROYED at the exact moment they go out of scope). AFAIK perl 6 is going to implement a scheme like this - which means you won't be able to count on "timely destruction" in perl 6 (at least, last time I looked).


In reply to Re^2: Memory leaks and reference counting within Perl. by Joost
in thread Memory leaks and reference counting within Perl. by DigitalKitty

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (8)
As of 2024-04-18 16:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found