Finding the memory hogs

nik on 2005-10-02T20:10:06

I sent this to the london.pm mailing list, and was surprised to get few responses. That probably means it's a hard problem. Still...

I'm having a stab at reducing the memory footprint of a Perl application I'm working with. When it's running it's ~80MB resident. I know it plays fast and loose with memory, allocating hashes and the like at the drop of a hat. What I'd like to know are the long hanging fruit that I can try and recode to be a little more memory friendly.

Devel::Symdump + Devel::Size gets me some of the way there. I can instrument the application by waiting until it's gone through its initialisation phase (after which the memory usage is reasonably constant), and then walk the symbol table, dumping the size of everything that's found.

But, natch, that won't work for lexical variables, many of which have been created in subs and had references returned.

Poking through CPAN hasn't turned up anything useful (although some of the B:: namespace looks like it could be coerced in to this). Anyone got any pointers to approaches that are likely to work?

Any takers?


tried perl monks?

TeeJay on 2005-10-03T15:27:38

I don't usually go there - but I've seen plenty of 'hard stuff' resolved on there when browsing the interweb for solutions.