develooper Front page | perl.perl5.porters | Postings from November 2009

Re: [perl #67838] lvalue substr keeping lexical alive

Thread Previous | Thread Next
From:
H.Merijn Brand
Date:
November 27, 2009 01:44
Subject:
Re: [perl #67838] lvalue substr keeping lexical alive
Message ID:
20091127104343.09874c56@pc09.procura.nl
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;

especially safe when $s is an object (e.g. a DBI statement handle) that
may contain big structures.

-- 
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About