It seems there is a memory leak in the C part of
Net::RawIP while running on Solaris 8 with ActivePerl 5.8.6.
As it turnes out I think I happened to fixed it by free-ing some memory that was mallocated...
Anyway I would like to write a test running the relevant function in a loop and checking the total memory use of my script before and after. I would like to do it in some platform independent way (at least among Unix/Linux and the like) and preferable to have it in a Perl module so I can just write a simple test.
Is there any module out there to report total memory usage of the current script? If not what tool is there to do it?
Update:
Thanks to McDarren I found Proc::ProcessTable that
solved the problem.
Re: total memory usage of process
I'm not sure if either of these are exactly what you are looking for, but
Test::Memory::Cycle looks interesting, as does
Memchmark..
Re^2: total memory usage of process
The first one is for existing perl variables, not relevant in my case.
Memchmark is promising, especially the
Proc::ProcessTable module it is using internally.
Re: 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 its fairly standard for Linux, but Im 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(";
chomp $data;
$fh->close;
my @procinfo = split(/\s+/,$data);
print "$$ memory = ",$procinfo[22] ," bytes\n";
Re: total memory usage of process
In addition to banger's stat suggestion, if you are running X, I use a personal tool called MeM, which displays a little Tk window in the corner of the screen, with the current usage. See
node 336856