Manymonks have mentioned your second my, and the fact that circular refs are needed to create leaks.
What I have to add is a module I recently became aware of, Data::Structure::Util, which is an easy way to get your circular refs cleaned out - circular_off($structure). Less recently useful were Devel::Cycle and Test::Memory::Cycle, which is based on the former. I always Test::Memory::Cycle to make sure that I've not overlooked something, and also to make sure, before I Scalar::Util::weaken, that the circular ref really exists.
There are also some modules that keep track of objects surviving into global destruction, like Devel::ObjectTracker or Devel::Leak::Object, but these I've found to be less useful, because they're a bit more of a hassle.
In reply to Re: Memory leaks and reference counting within Perl.
by nothingmuch
in thread Memory leaks and reference counting within Perl.
by DigitalKitty
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |