diff options
author | Gurusamy Sarathy <gsar@engin.umich.edu> | 1997-08-07 00:00:00 +0000 |
---|---|---|
committer | Tim Bunce <Tim.Bunce@ig.co.uk> | 1997-08-07 00:00:00 +1200 |
commit | bc44cdafae83e0dac3f8fcc1b06f85be485291c6 (patch) | |
tree | 13f613e911d8114a2b0f36d02e65671a8d73e0ac /scope.c | |
parent | 9a1ce46c336d20e36c6e5d34d0167ffdb7a5cdff (diff) | |
download | perl-bc44cdafae83e0dac3f8fcc1b06f85be485291c6.tar.gz |
object never destructs
On Sun, 13 Jul 1997 11:20:24 EDT, Andrew Pimlott wrote:
>package mytest;
>sub DESTROY { warn "Death"; }
>package main;
>{
> my $joe;
> my $moe;
> $moe = bless \$joe, 'mytest';
> print "Leaving block\n";
>}
>print "Left block\n";
Thanks for that excellent test case. Perl optimizes the
memory management of lexicals by not actually deallocating
unreferenced lexicals when the block exits, in order to
reuse them when the block is reentered. This of course
fails to destruct objects at the end of blocks.
A patch that fixes the problem for all object datatypes
is attached.
p5p-msgid: 199707131955.PAA29655@aatma.engin.umich.edu
Diffstat (limited to 'scope.c')
-rw-r--r-- | scope.c | 3 |
1 files changed, 2 insertions, 1 deletions
@@ -536,7 +536,8 @@ I32 base; case SAVEt_CLEARSV: ptr = (void*)&curpad[SSPOPLONG]; sv = *(SV**)ptr; - if (SvREFCNT(sv) <= 1) { /* Can clear pad variable in place. */ + /* Can clear pad variable in place? */ + if (SvREFCNT(sv) <= 1 && !SvOBJECT(sv)) { if (SvTHINKFIRST(sv)) { if (SvREADONLY(sv)) croak("panic: leave_scope clearsv"); |