Hi,
I'm trying to understand whether a large program I'm dealing with has memory leaks. I did some search, and in all the places where Perl's memory use is discussed, it says something like this:

- Perl's garbage collector works by counting references.
- If your code contains circular references, the garbage collector will not be able to free that memory, as the reference count won't go down to 0.
- The simple solution is to use weakened refs.
- If you don't do this, the memory will not be freed until the program is terminated.

Now, the code I'm dealing with certainly contains circular references. But before I start looking up all those and weakening them, I wanted to understand something:

If I reach the end of my program, and it terminates as it should - is the memory with the circular references freed anyway? If it is, does it mean that technically, there can be no such thing as a memory leak in perl as long as the program isn't interrupted? What happens if it is interrupted? I couldn't find definite answers to these questions...

Thanks a lot!

In reply to Memory and garbage collection by Anonymous Monk

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.