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

Re: How do I free memory allocated to an array

by Sewi (Friar)
on Apr 22, 2009 at 12:28 UTC ( [id://759262]=note: print w/replies, xml ) Need Help??


in reply to How do I free memory allocated to an array

You should look at the two types of "free" memory:
1. Memory returned to the operating system for re-allocation to (other) processes.
2. Memory returned to the internal "free memory" pool of the process.

Even if you may not be able to return memory to the operating system, you may be able to re-use it within your process. Try the following sample:

sub S { system "ps u $$"; } &S; my $X = "x"x10240000; &S; undef $X; &S; $X = "x"x10240000; &S; undef $X; &S;
You'll see that perl really returns (parts of) the memory used for $X after is has been destroyed. (I didn't expect this, too :-) ).

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2024-04-23 13:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found