in reply to out of memory problem after undef
#!/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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: out of memory problem after undef
by ikegami (Patriarch) on Dec 03, 2008 at 20:35 UTC |