On Wed, Jan 10, 2001 at 01:23:02PM -0500, Charles Lane wrote: > We leak an SV every time Opcode::_safe_call_sv is called (yes, it's > *shocking* I know! *Dozens* of bytes right down the drain! ;-) On the behalf of the Society for the Avoidance of Wasted Bytes I would like to take this opportunity to thank you for your contribution. > To have a "clean" %INC for a Safe partition, we save save_hash(PL_incgv). > This actually (after saving the hv) creates a new, blank hv in its > place. > > Then, we fetch/create a new %INC and overwrite the hv left over from > the save_hash, without freeing it...thus the memory leak. > > Here's a little patch to fix. > > diff -uBb ext/Opcode/Opcode.xs-orig ext/Opcode/Opcode.xs > --- ext/Opcode/Opcode.xs-orig Tue Jan 9 08:01:12 2001 > +++ ext/Opcode/Opcode.xs Tue Jan 9 08:08:40 2001 Thanks, applied. > @@ -271,6 +271,7 @@ > > /* %INC must be clean for use/require in compartment */ > save_hash(PL_incgv); > + sv_free((SV*)GvHV(PL_incgv)); /* get rid of what save_hash gave us*/ > GvHV(PL_incgv) = (HV*)SvREFCNT_inc(GvHV(gv_HVadd(gv_fetchpv("INC",TRUE,SVt_PVHV)))); > > PUSHMARK(SP); > -- > Drexel University \V --Chuck Lane > ======]---------->--------*------------<-------[=========== > (215) 895-1545 _/ \ Particle Physics > FAX: (215) 895-5934 /\ /~~~~~~~~~~~ lane@duphy4.physics.drexel.edu -- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack CohenThread Previous