|P is for Practical|
Freeing memory used by arraysby monktim (Friar)
|on Dec 04, 2003 at 14:47 UTC||Need Help??|
monktim has asked for the wisdom of the Perl Monks concerning the following question:
According to the Learning Perl book, truncating an array does not recover its memory. To feee memory I need to undef the array like this undef(@array). It also says that the memory doesn't always get free because not many operating systems support this. I find this strange as I've never had this problem in other languages.
I'm using Win2K and not much memory gets free when I undef my array. When I run the script below the @array takes ~76,000K in memory when I hit the breakpoint. After undef(@array) gets executed the memory only goes down to ~72,000K. If I continue the loop and watch memory it'll fluctuate between these two numbers.
Is there another way to free the memory? Does anyone else find this behavior strange? I must be missing something, perhaps some monks can enlighten me.
The memory is even kept after the array goes out of scope.