tags:

views:

40

answers:

1

Is there something in perl similar to PHP's memory_get_peak_usage? For example, in PHP I can stick in the line:

echo "Peak memory usage: " . (memory_get_peak_usage(true) / 1024 / 1024) . " MB\r\n";

and it does pretty much what it says. I need a way to get the same sort of information in a perl script.

I should note that this for a CGI script, and based on a shared webhost - not sure if that matters.

+2  A: 

You can use Devel::Peek. The mstat function prints a large number of memory statistics at any point you like.

Alternately you can call your perl script with the PERL_DEBUG_MSTATS environment variable set:

PERL_DEBUG_MSTATS=2 perl myscript.pl

See this article for information on how to decipher these statistics.

rjh