D
David Morel
Hi all,
I am having a small problem with memory management.
Here is my code:
my $num = 500000;
my @paths;
# memory usage is now low
sleep 5;
for (my $i = 0; $i <= $num; $i++) {
my $path = [$i, $i];
push @paths, $path;
}
# memory usage is now high
sleep 5;
undef @paths;
# now I want to return to low memory usage,
# but the above undef statement doesn't get the job done!
sleep 5;
Notice that in the second block of code I create an array with 500000
pointers. Then, in the third block of code, I delete all of the
pointers with undef (I think). Then why doesn't the garbage collector
kick in? I mean the total memory usage after the second block is about
75MB, and then it only drops to about 73MB... (as opposed to about
1MB) ?
Thanks!
I am having a small problem with memory management.
Here is my code:
my $num = 500000;
my @paths;
# memory usage is now low
sleep 5;
for (my $i = 0; $i <= $num; $i++) {
my $path = [$i, $i];
push @paths, $path;
}
# memory usage is now high
sleep 5;
undef @paths;
# now I want to return to low memory usage,
# but the above undef statement doesn't get the job done!
sleep 5;
Notice that in the second block of code I create an array with 500000
pointers. Then, in the third block of code, I delete all of the
pointers with undef (I think). Then why doesn't the garbage collector
kick in? I mean the total memory usage after the second block is about
75MB, and then it only drops to about 73MB... (as opposed to about
1MB) ?
Thanks!