This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
object never destructs
authorGurusamy Sarathy <gsar@engin.umich.edu>
Thu, 7 Aug 1997 00:00:00 +0000 (00:00 +0000)
committerTim Bunce <Tim.Bunce@ig.co.uk>
Wed, 6 Aug 1997 12:00:00 +0000 (00:00 +1200)
commitbc44cdafae83e0dac3f8fcc1b06f85be485291c6
tree13f613e911d8114a2b0f36d02e65671a8d73e0ac
parent9a1ce46c336d20e36c6e5d34d0167ffdb7a5cdff
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
scope.c
t/op/ref.t