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.
You can use Devel::Peek. The
mstatfunction prints a large number of memory statistics at any point you like.Alternately you can call your perl script with the
PERL_DEBUG_MSTATSenvironment variable set:See this article for information on how to decipher these statistics.