Working on one project I stay before problem of memory requirements. Tried to use tied hashes I doscover taht my code eat more and more of my memory. Each iteration through all data in that hash cost me other memory space. After some experiments I've got following code which demonstrate this behaviour. It looks like problem with Storable.
What goes on? Where is my memory?
#!/usr/bin/perl -w
use strict;
use Set::Scalar;
use Storable qw(nfreeze thaw);
my $iterations = 20;
my $set_count = 100;
my $data = 'abcdefgh';
srand();
for (my $cycle = 0; $cycle < $iterations; $cycle ++) {
{
my $tmp = $data;
my $r_arr;
$tmp .= chr(int(rand(26))+65);
for (my $set = 0; $set < $set_count; $set ++) {
my $scalar_set = Set::Scalar->new(split(//, $tmp));
push @$r_arr, thaw( nfreeze( $scalar_set ) );
}
}
&procinfo;
}
exit 0;
sub procinfo {
my @stat;
open( STAT , '<', "/proc/$$/stat" ) or die "Unable to open stat file
+";
@stat = split /\s+/ , <STAT>;
close( STAT );
printf "Vsize: %3.2f MB\t", $stat[22]/1048576;
print "RSS : $stat[23] pages\n";
}