in reply to total memory usage of process

look in /proc/ for a file called 'stat' under a directory with the pid id of the process. Open it he 22nd field (starting at 0) is the amount of 4k memory pages used. We used to do it this way on Debian and I think it’s fairly standard for Linux, but I’m digging the 22nd field out from my (very leaky) memory. Example
#!/usr/bin/perl -w use strict; use FileHandle; my $pid = $$; my $fh = FileHandle->new("</proc/$pid/stat"); my $data = <$fh>; chomp $data; $fh->close; my @procinfo = split(/\s+/,$data); print "$$ memory = ",$procinfo[22] ," bytes\n";