develooper Front page | perl.perl5.porters | Postings from October 2008

Re: [perl #59268] PerlIO::via leaks memory at a high rate

Thread Previous | Thread Next
Nicholas Clark
October 26, 2008 10:41
Re: [perl #59268] PerlIO::via leaks memory at a high rate
Message ID:
On Wed, Sep 24, 2008 at 01:40:20AM -0700, Marc Lehmann wrote:

Sorry about the delay in anyone replying. I don't think that anyone (alive)
is familiar with this code.

Having been forced to have a look at it (5.8.9 show stopper) I can't say that
it fills me with joy.

> If I had to make a very quick guess, could it be that the
> pseudo-filehandle creates via newGVgen creates a new _GEN_xxx symbol in
> the ...::bla package that never ever gets freed?
> Indeed, adding this line into the while loop:
>    warn keys %PerlIO::via::bla::;
> creates successively longer output lines. Could that mean that
> newGVgen leaks?

I am suspicious of this part of the code of via.xs

	    if (!s->fh) {
		GV *gv = newGVgen(HvNAME_get(s->stash));
		GvIOp(gv) = newIO();
		s->fh = newRV((SV *) gv);
		s->io = GvIOp(gv);

I suspect that yes, it practical terms it is leaking at the Perl level, in
that all the memory is still reachable, and will be correctly accounted for
at interpreter exit, but the code never thinks to clean up its temporaries
immediately after it has finished with them.

I'm afraid that I'm not going to have time to make a fix that I'm comfortable
with in time for 5.8.9. However, I don't see any particular reason why a
fixed version can't be put on CPAN subsequently, which would allow you (or
anyone else) to have a dependency on it, and hence "fix" existing perl

Nicholas Clark

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About