Occasionally you'll have a module that requires circular references. Of course, you'll want it to be well-behaved, so you use weaken statements on selected references so that, when the objects are freed, all the memory does indeed go away.
Putting the weaken statement in the right place can be tricky, and unlike most bugs which are all too evident when you don't get the answer you need, any mistake results in a memory leak, which you might take a while to notice.
So I wrote a test module for weakening. Give it an an anonymous subroutine which returns a reference, and it will undef the result, then check that all the memory was indeed freed just the way it was supposed to be.
Does this duplicate anything currently in CPAN? If not, I'll document it, package it, and contribute it.
UPDATE: A beta release is now in CPAN.
jeffrey kegler
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.