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

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

Thread Previous | Thread Next
From:
Eric Brine
Date:
November 17, 2009 10:45
Subject:
Re: [perl #67838] lvalue substr keeping lexical alive
Message ID:
f86994700911171045r3d607cd6p489a6210c7f90d35@mail.gmail.com
On Mon, Nov 16, 2009 at 4:03 PM, Kevin Ryde <user42@zip.com.au> wrote:

> "Eric Brine via RT" <perlbug-followup@perl.org> writes:
> >
> > What's the impact of the bug?
>
> Is that a question for me?


It was rhetorical. The answer followed.


>  > Delaying the freeing of strings has next to no impact.
>
> If it's a big string it would use up memory for a lot longer than you'd
> expect.


Yes, but Perl already does that all over the place intentionally. For
example, 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. If that's the extent of the problem, it's not a bug.

If the scalar is tied or has other magic it could be bad to delay its
> destructor,


I must have been tired, but I forgot magic had destructors. I may have
underestimated the impact. I definitely understated it.


> > - Don't fix until a better solution is found.
>
> I wouldn't mind knowing a way to identify scalars held alive like this,
> so as to excuse them from Test::Weaken or similar leak checking.
>

Since TARG variables are stored in the pad, you could go through the pad
looking for PVLVs that have associated variables. It may not be the perfect
answer (any maybe you can refine it by looking at the flags), but it should
be a very good heuristic.

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