Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
A way to test that circular references are actually freedby Jeffrey Kegler (Hermit) |
on Oct 10, 2007 at 00:42 UTC ( [id://643834]=perlmeditation: print w/replies, xml ) | Need Help?? |
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
Back to
Meditations
|
|