How does a Perl script know its own amount of memory?

I have a long Perl script, and I would like to tell it (and tell) how much memory it uses. I would like to receive this information both on Linux and on Windows, and also, possibly, on Mac OS X.

+7
linux windows memory perl macos
source share
3 answers

These Perl modules can help you:

+6
source share

This will show you how to:

http://perldoc.perl.org/Devel/Peek.html

Also http://perldoc.perl.org/perlguts.html

and, man pages for perldebug and perldebguts.

+5
source share

This is fast and dirty and, above all, the CPAN method. It works on any OS that provides the / proc file system, that is, derivatives of Linux and Unix, including Mac OS X, as well as Cygwin for Windows:

perl -e 'print qx{ grep VmSize /proc/$$/status };' 
+1
source share

All Articles