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


in reply to Depth First Search through Digraph Results in Memory Leak

While I've not dug into it in any depth, odds are you're getting bit by a bug in perl's pad caching.

When you go recursive on a sub, it triggers a more aggressive caching scheme for the lexical pad for a sub, and it looks like as part of that a top-level pad's not getting cleaned up when it ought to be. (It's also possible this is triggering a cleanup delay/bug in the top-level pad)

If you can, try boiling this down as small as possible and fire it off as a bug report with perlbug.