in reply to How to get the amount of RAM

Here is one way to find the amount of memory used by the entire Perl process on Unix systems.

me@mybox:~/sandbox $ perl -e 'while (1) {}' & [1] 28892 me@mybox:~/sandbox $ ps -o vsz -p 28892 VSZ 77916

That's 77 MB used in that perl process.

Replies are listed 'Best First'.
Re^2: How to get the amount of RAM
by zwon (Abbot) on Nov 09, 2011 at 13:03 UTC

    I usually find rss and sz more useful comparing to vsz

      And for the ram used by perl you can do this also...

      print `memstat |grep perl`;

      you can ask for a specific process also, following the former example

      print `memstat -p 28892`; __END__ 592k: PID 5273 (/usr/bin/perl) 116k( 108k): /lib/ld-linux.so.2 28892 92k( 84k): [08:01]:258781 28892 44k( 36k): [08:01]:258783 28892 16k( 8k): [08:01]:258784 28892 152k( 144k): [08:01]:258791 28892 1372k( 1356k): [08:01]:258796 28892 1404k( 1396k): /usr/bin/perl 28892 1500k( 0k): [08:06]:242490 28892 -------- 5288k ( 3132k)

      for memory use inside a specific part of a perl script see also malloc() and memstat() or -DL and warn('!') marks