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.