Can someone look at a subroutine for me? Specifically, after
this (at bottom of email) subroutine runs, it increases my
RSS by 6 megs, and shouldn't do that. (here it has indexed
133798 files)
This is the program before the checkstuff subroutine runs:
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
16370 root -1 -20 94732 92M 1292 S < 0.0 26.8 0:54 ldir.pl
Here it is after the checkstuff subroutine runs:
PID USER PRI NI SIZE RSS SHARE STAT %CPU %MEM TIME COMMAND
16370 root 9 -20 98.5M 98M 1292 S < 0.0 28.5 1:07 ldir.pl
Here is some data about what the subroutine is doing:
There are two main indexes for file system data I have
in memory:
%{$files} is a hash of hashes of hashes of
arrays. @{ ${$files}{dirname}{basename} } is a list
of some stat data and an md5sum. (md5,dev,ino,siz,mtime)
%{$sums} is a hash of hashes of hashes hashes that serves
to cross reference the md5sum to the file itself. Quite
simply, ${$sums}{sum}{dir}{file} = 0 and then I can find
out which files have a certain md5sum, and access their
stat data by going to the other hash (%{$files}) which is
indexed by dir and file.
checkstuff does simple sanity checking by walking the hashes
and counting elements. What is wrong with it???
... <snipped lots of perl code>
print "Ok, now check my mem usage!\n";
$temp=<STDIN>;
checkstuff();
print "Ok, now check my mem usage!\n";
$temp=<STDIN>;
sub checkstuff {
my $temp=0;
my $temp2=0;
my $sum;
my $ref;
my $dir;
my $file;
my @files;
my @dirs;
my $name="checkstuff";
foreach $sum (sort keys %{$sums}) {
@dirs=(sort keys %{ ${$sums}{$sum} });
foreach $dir (@dirs) {
@files=(keys %{ ${$sums}{$sum}{$dir} });
$temp += $#files+1;
}
}
foreach $dir (sort keys %{$dirs}) {
foreach $file (sort keys %{ ${$dirs}{$dir} }) {
$temp2++;
}
}
print "\t$name -> MD5sums($temp) FileDirs($temp2)\n";
undef $temp;
undef $temp2;
undef $sum;
undef $ref;
undef $dir;
undef $file;
undef @files;
undef @dirs;
undef $name;
return();
}
--
Hob Goblin
[EMAIL PROTECTED]
"Look into my nipples of the future..." -Really Really Big Man