On 18 May 2011 20:30, Paul Johnson <p...@pjcj.net> wrote: > 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.
lets say I have a really big perl program, if I let the it run, the memory usage will always increase until it exits? is this the same for other language like c++ or java? Thank you all! Jim -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/