in reply to Uncollected garbage leads to swapping ...

I'm curious what your code looks like. While it doesn't surprise me if the OS fails to reclaim freed memory, I'm surprised that you're finding that after a variable goes out of scope its memory isn't in some way reused by Perl. Could you boil down a snippet that does what you're talking about?

Here is a test snippet where you can prove to yourself that Perl does re-use its own memory space. The following snippet maintains a continuous loop where 10,001 hash elements are assigned integer values, and then the hash falls from scope and is recreated again. If the same memory isn't reused by Perl, it should take no time at all for this snippet to fill all available memory. But as I watch Perl's memory usage in the Windows Task manager, it never jumps above about 4,300k, so my test doesn't reproduce your issue. At least in this case, Perl does the right thing.

use strict; use warnings; while (1) { my %hash; @hash{0..10000} = (0..10000); }

By the way, (this is completely unrelated to your question) this snippet does get me a little wierd error intermittantly upon termination with a CTRL-C break:

Terminating on signal SIGINT(2) Terminating on signal SIGINT(2) Attempt to free unreferenced scalar: SV 0x188d214 at C:\Perl\Scripts\m +ytest.pl line 9.

...line nine is the line with the hash slice on it. I'm using Active State Perl 5.8.2, binary build 808. The error occurred twice out of a few dozen repeated attempts. Of course this error is unrelated to your question, but curious nevertheless.


Dave