in reply to Profiling memory

Outside of the perl world (and hence of little direct use to you), you have valgrind massif, which does pretty much what you ask. Memprof (if it is still working) and exmap (which is more focussed on fairly apportioning actually-used RAM amongst multiple processes, accounting for the vagaries of virtual memory).

Within perl, I have in the past written code which walks all package variables in all packages (I did it directly, starting at the %main:: hash, but there's probably a module to make that easier), using Devel::Size::total_size to work out the size of each. This worked well fairly well (sorry - I was unable to release it, but it was a fairly quick hack).

This approach would of course miss any leaked memory (which was no longer rooted in a package var) as well as anything only reachable via a lexical - although that might be fixable with PadWalker. It would also double-count any memory which was reachable via more than one place.

The code basically took a snapshot of all vars and sizes and then gave diffs against it on each subsequent invocation, looking for growing data structures over time.

It was all pure perl and I guess it wouldn't take more than a day or two to recreate from the above description.