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;
}
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.