From: [email protected]
[mailto:[email protected]] On Behalf Of
Rothenmaier, Deane C.
Sent: 08 March 2012 15:00
To: [email protected]
Subject: Quick memory-recovery question--a point of information
> Hi, gurus. This should be an easy one, and it is a minor one... I have an
> array which is declared and used
> inside a lexical scope, viz.:
>
> {
> my @chunk = split( /\n/, $data_line); # $data_line is a chunk of "lines",
> separated by newlines, in one scalar > string.
> ...
> # Do stuff with members of @chunk
> ...
> undef @chunk;
> }
>
> Now here's my question, am I gaining anything in terms of memory use by
> explicitly undef-ing the array, or can > I expect more or less the same
> result if I just leave disposing of the array's memory to leaving the scope?
> The Camel tells me that undef @x recovers the memory allocated to @x, and
> that leaving a scope does, well,
> something, to the allocation of a variable declared inside the scope, but is
> mute on whether the net result is > the same.
I would expect the undef to be unnecessary. Unless you stored a reference to
the array somewhere during that scope, it will get garbage collected when the
scope exits. If you wanted to recover the memory before the end of scope for
some reason, although I can't think of a good one one at the moment, then by
all means use undef, or possibly @chunk = ().
HTH
--
Brian Raven
Please consider the environment before printing this e-mail.
This e-mail may contain confidential and/or privileged information. If you are
not the intended recipient or have received this e-mail in error, please advise
the sender immediately by reply e-mail and delete this message and any
attachments without retaining a copy.
Any unauthorised copying, disclosure or distribution of the material in this
e-mail is strictly forbidden.
_______________________________________________
Perl-Win32-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs