Suspicion confirmed. Thanks, Brian! (All you other folks out there typing away can stop, now... Thanks to you, too.)
Deane Rothenmaier Programmer/Analyst - IT-StdCfg Walgreens Corp. 2 Overlook Point #N51022D MS 6515 Lincolnshire, IL 60069 224-542-5150 There were no survivors in the sixties, only casualties, prisoners of war and veterans who cried out in the dark. - Pat Conroy, Beach Music -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Brian Raven Sent: Thursday, March 08, 2012 9:18 AM To: [email protected] Subject: RE: Quick memory-recovery question--a point of information 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 _______________________________________________ Perl-Win32-Users mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
