Clear questions and runnable code
get the best and fastest answer
Strange memory growth?by meetraz (Hermit)
|on Nov 07, 2003 at 20:08 UTC||Need Help??|
meetraz has asked for the
wisdom of the Perl Monks concerning the following question:
Can anybody explain why this code doesn't do what I think it should?
I always thought that if you declare a lexical variable (such as my $foo) inside a block, that it gets freed / garbage-collected at the end of the block.
My understanding is that while perl may not return allocated memory back to the OS, it will at least reuse earlier freed memory, rather than allocating more from the OS.
However, the code above will grow by 8M every 5 seconds. If you include the if-loop enough times, it will consume all available memory (at least on Win2k, perl 5.6.1 and 5.8.0)