in reply to Memory leak

Code just taking up more memory does not necessarily mean you've got a memory leak*. It may be that the algorithm chosen just takes up more memory while it's working, or that your code is inefficiently structured - i.e. you're keeping a lot of variables around that you don't need instead of using simple blocks/subroutines that automatically destroy unused variables.

* IMO, a memory leak is what happens when you've got memory allocated that is *unreachable*. Perl is reasonably good at detecting and clearing those, except for circular references. If that's what you're trying to detect, you may want to take a look at Test::Memory::Cycle (note: I've never used it myself)