develooper Front page | perl.perl6.language | Postings from February 2001

Re: Garbage collection (was Re: JWZ on s/Java/Perl/)

Thread Previous
James Mastros
February 14, 2001 09:37
Re: Garbage collection (was Re: JWZ on s/Java/Perl/)
Message ID:
On Wed, Feb 14, 2001 at 01:25:26PM -0300, Branden wrote:
> The problem is when objects are shared by
> many variables. For example:
>     $a = new Object();
>     $b = $a;
>     ...
>     destroy $a;           ## would call $a->DESTROY()
>     ...
>     $b->doSomething();    ## should die. Note that $b is not undef
Hmm?  (Assuming destroy() autoderefs.)  destory $a would call %$a->DESTORY
(assumption of hash for example), and remove %$a from the
symbol-table/otherwise make it nonexistant.  Then $b->doSomthing() will fail
because it's a ref to undef.

> And there would be another problem when the GC tries to collect the memory
> used by the object, because it usually calls DESTROY on collected objects.
> Calling it for this object would mean calling it twice, what is probably a
> very wrong thing to do.
Oh, I rather assumed that there would be a "invalid" marker of some sort.
It's neccessary (I think) for a pool, which I assumed.  Bad James, bad.

     -=- James Mastros
"All I really want is somebody to curl up with and pretend the world is a
safe place."
AIM: theorbtwo 	     homepage:

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