I can't say how it would work on win32, but on linux, I've had luck with Perl releasing huge
memory back to the system, if the array was in a thread, and the thread was joined/finished.
#!/usr/bin/perl
use threads;
use threads::shared;
use warnings;
use strict;
print $$,"\n"; # top -p $$ to check
my $alive:shared = 0;
my $thr = threads->create(\&display);
print "check mem use, then hit any key\n";
<>; #check mem use
$alive = 1;
$thr->join;
print "check mem use, then hit any key\n";
<>; #check mem use
$alive = 0;
my $thr1 = threads->create(\&display);
print "check mem use, then hit any key\n";
<>; #check mem use
$alive = 1;
$thr1->join;
print "check mem use, then hit any key to finally exit\n";
<>; #check mem use
sub display {
my @array;
foreach (1..10000000){
push @array, 'aaaa';
}
while(1){
last if $alive;
sleep 1;
}
undef @array;
return;
}