Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Clearing an Array of Array's from memory

by Elian (Parson)
on Aug 29, 2003 at 17:26 UTC ( #287767=note: print w/replies, xml ) Need Help??


in reply to Re: Clearing an Array of Array's from memory
in thread Clearing an Array of Array's from memory

Letting a variable fall out of scope doesn't free up all its memory. The memory used for the members of an aggregate (array or hash) are generally freed, however the memory used for the structure of the variable (including scalars) aren't freed--they are instead saved in case the scope is re-entered. Notice:
use Devel::Size qw(size); $foo = 2; while ($foo--) { { my $bar; print Devel::Size::size(\$bar), " ", length($bar), "\n"; $bar = " " x 10000000; } }
prints
12 0 10000025 0
not
12 0 12 0
which is what you'd expect if the memory was actually freed on scope exit.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://287767]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (5)
As of 2017-02-19 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Before electricity was invented, what was the Electric Eel called?






    Results (293 votes). Check out past polls.