> > Oddly, if you just do
> >
> > my $sub = sub { $var; };
> >
> > it does not grow, definately something strange going on. Happens on
> > perl 5.004_04, 5.005_03 and 5.6.1.
>
> You mean this works for you?:
>
> while (1) {
>        {
>                my $var = 'x' x 500000;
>                my $sub = sub { $var; };
>        }
>        # $var and $sub should be gone, but memory is never freed
>        sleep 1; # Don't crash things =)
> }
>
> that's because your $sub goes out of scope.

The leaking behavior only happens when you use nested anonymous subs.  It
should always be possible to avoid it, although your code may look uglier.

> the other one seems like a
> bug.
>
> If I didn't miss something, it seems that we need to run this through p5p.

It's been known about for a while.  I'm not sure what the status of getting
a fix is.  I assume that it must be difficult to fix or it would have been
changed a long time ago.

- Perrin

Reply via email to