Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: out of memory problem after undef

by zentara (Archbishop)
on Dec 03, 2008 at 19:45 UTC ( [id://727787]=note: print w/replies, xml ) Need Help??


in reply to out of memory problem after undef

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; }

I'm not really a human, but I play one on earth Remember How Lucky You Are

Replies are listed 'Best First'.
Re^2: out of memory problem after undef
by ikegami (Patriarch) on Dec 03, 2008 at 20:35 UTC

    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

    Win32 does release back to the OS, but we're not talking about releasing back to the system. Releasing back to Perl is fine.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://727787]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found