I just had a discussion about variables going out of scope (for memory
considerations)
The idea was presented that variables go out of scope as soon they're
last referenced in a block, I always thought it was when the block ended.
I was just about to search for this and thought I'd ask to see if anyone
knew offhand...
In this example is it A or B?
I'm thinking 'B' but never heard of 'A' before but I suppose it could be
that way...
{
my $foo = load_100M_of_data();
print $foo; # $foo is using 100M of memeory ±
# A) $foo is now out of scope (and therefore no longer 100M of
memory) since its not used anywhere after that print() in this block
# 100 lines of code without any use of $foo
} # B) $foo is now out of scope (and therefore no longer using 100M of
memory)
I'm thinking its B and and the best way to reclaim the memory in this
case is to undef()ine $foo when its no longer used in the block.
Any insight would be very interesting no doubt :)
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>