On Fri, 27 Nov 2009 15:38:03 +0100, Eirik Berg Hanssen <Eirik-Berg.Hanssen@allverden.no> wrote: > "H.Merijn Brand" <h.m.brand@xs4all.nl> writes: > > > On Fri, 27 Nov 2009 11:41:19 +1100, Kevin Ryde <user42@zip.com.au> > > wrote: > > > >> "Eric Brine via RT" <perlbug-followup@perl.org> writes: > >> > > >> > lexicals aren't freed when they go out of scope. They stay > >> > allocated (along with their string buffer) for reuse the next time that > >> > scope is entered. > >> > >> Ah, I didn't know that. Makes it hard to work carefully with big > >> strings. You'd be tempted to free big things, above some threshold, on > >> the relative badness of time taken to malloc a new block. > > > > $s = undef; > > Did you mean undef($s), or did something change while I was not > looking? ;-) Both is allowed, but indeed only 'undef ($x)' frees the variable. I was not aware of the difference until I just checked. Look at the flags: $ perl -MDP -wle'$_="x"x10;DDump$_;$_=undef;DDump$_' SV = PV(0x743158) at 0x782198 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x753660 "xxxxxxxxxx"\0 CUR = 10 LEN = 16 SV = PV(0x743158) at 0x782198 REFCNT = 1 FLAGS = () PV = 0x753660 "xxxxxxxxxx"\0 CUR = 10 LEN = 16 $ perl -MDP -wle'$_="x"x10;DDump$_;undef$_;DDump$_' SV = PV(0x743158) at 0x782198 REFCNT = 1 FLAGS = (POK,pPOK) PV = 0x753660 "xxxxxxxxxx"\0 CUR = 10 LEN = 16 SV = PV(0x743158) at 0x782198 REFCNT = 1 FLAGS = () PV = 0 $ > Eirik, who doesn't use that feature often either -- H.Merijn Brand http://tux.nl Perl Monger http://amsterdam.pm.org/ using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00, 11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3. http://mirrors.develooper.com/hpux/ http://www.test-smoke.org/ http://qa.perl.org http://www.goldmark.org/jeff/stupid-disclaimers/Thread Previous | Thread Next