Profiling heap memory usage on perl programs

2019-07-15 13:34发布

问题:

I have written a perl program to operate on huge datasets. I am trying to profile its excution in terms of its memory usage. Tried using valgrind on small datasets, but it slows down the execution dramatically. I am looking for just heap profiling. Could you guys suggest some ways ?

回答1:

When I used Google and the search term 'perl memory profile', one of the first items points to the Perl module Devel::Size as one way of spotting memory usage. There are also memory leak detector modules lurking around.



回答2:

The new Devel::SizeMe module provides detailed visibility into the heap memory usage of a perl program or data structure. There's a blog post introducing Devel::SizeMe, including links to talk slides and screencast.



回答3:

use Memchmark.



回答4:

We used Devel::Leak. To work fully, you need a debugging compiled Perl, but even without that, you can count and log the number of allocated scalars, hashes, and arrays, as your code runs, at various key points. That was enough to pin down the leaks we had.