So yes, I have patched the file scope.c. Because a lot of the (existing) code does not use a explicit undef on a scope exit (of course, does this imply a variable declared with 'my').diff -urN perl-5.8.8/scope.c perl-5.8.8_/scope.c --- perl-5.8.8/scope.c 2005-09-30 15:56:51.000000000 +0200 +++ perl-5.8.8_/scope.c 2009-02-23 16:23:40.000000000 +0100 @@ -946,14 +946,26 @@ SvREFCNT_dec(AvARYLEN(sv)); AvARYLEN(sv) = 0; } + av_undef((AV*)sv); break; case SVt_PVHV: hv_clear((HV*)sv); + hv_undef((HV*)sv); break; case SVt_PVCV: Perl_croak(aTHX_ "panic: leave_scope pad code"); default: SvOK_off(sv); + const U32 padflags + = SvFLAGS(sv) & (SVs_PADBUSY|SVs_PADMY|SVs_PADTMP); + switch (SvTYPE(sv)) { /* Console ourselves with a ne +w value */ + case SVt_PVAV: *(SV**)ptr = (SV*)newAV(); break; + case SVt_PVHV: *(SV**)ptr = (SV*)newHV(); break; + default: *(SV**)ptr = NEWSV(0,0); break; + } + SvREFCNT_dec(sv); /* Cast current value to the w +inds. */ + SvFLAGS(*(SV**)ptr) |= padflags; /* preserve pad natur +e */ + break; } }
print "Start: >".$$."<\n";<>; { my @arr; $arr[$_]=$_ foreach(1 .. 1000000); print "How Many?\n";<>; #->not needed: undef @arr; } print "Done, how many?\n";<>;
In reply to Re: Perl Garbage Collection, again
by pkirsch
in thread Perl Garbage Collection, again
by pkirsch
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |