http://www.perlmonks.org?node_id=1047585


in reply to Re: Perl Variables Being Retained
in thread Perl Variables Being Retained

Specifically in terms of “Perl not cleaning up the memory,” also note the weaken in Scalar::Util.   If you have data structures referring to one-another such that a circular reference is formed, memory does not clean up but rather “leaks.”   You avoid this by weakening one of the links in the chain.   Test::Memory::Cycle is another tool that is designed specifically to look for these circular reference-chains.