On Wed, May 18, 2011 at 05:16:23PM -0700, Jim Green wrote: > Hello List! > I have a quick question about memory release in perl: > > { > my @array; > > foreach my $n (1..1e7 ) { > push @array, $n; > print "$n\n"; > } > } > > print "sleeping\n"; > sleep 600; > > after the code block, I epxect memory usage to drop to almost zero > because @array went out of scope. but when I do top after it executes > after the code block it still has huge memory usage.. > > Could anyone give me some explanation?
In general perl won't release memory back to the system, but will keep it around to be (possibly) reused later. If you subsequently create another similarly sized array you should notice that memory use remains roughly the same. -- Paul Johnson - p...@pjcj.net http://www.pjcj.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/