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

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

Thread Previous | Thread Next
From:
Branden
Date:
February 12, 2001 08:50
Subject:
Re: Garbage collection (was Re: JWZ on s/Java/Perl/)
Message ID:
OE26sd32HtkJJfYCank00005dbc@hotmail.com
Buddha Buck wrote:
> At 01:45 PM 02-12-2001 -0300, Branden wrote:
> >Am I too wrong here?
>
> It's... complicated...
>

Agreed.

> Here's an example of where things could go wrong:
>
> sub foo {
>          my $destroyme1 = new SomeClass;
>          my $destroyme2 = new SomeClass;
>          my @processme1;
>          my @processme2;
>          ...
>          push @processme1, $destroyme1;
>          push @processme2; $destroyme2;
>          ...
>          return \@processme2;
> }
>
> If $destroyme1 and $destroyme2 are ref-counted, but @processme1 and
> @processme2 are not, ...
>

Hey, there's no way for this to work! Anything that can be stored in $ can
also be stored in @ or %, so having them with different GC's wouldn't
probably work.

Actually I was thinking something like PMCs ($@%) being copy-GCed and
referred objects (new SomeClass) being refcounted. In this case above, every
operation would use refcount's, since they're storing objects in PMCs. What
wouldn't use refcount is

    foreach $i (@a) {
        $i++;
    }

Normally $i would be an alias to an element of @a, that means it would
reference the same PMC that one element of @a is referring to. If in this
case copy-GC is used, probably the GC wouldn't even be called inside of the
loop, and the whole operation would be done without overhead, even of
refcounting, even of copy-GC.



I really don't know if this would be a win over full refcounting, since the
most things (objects) would continue to use refcounting, and less used
things (aliases) would not. I think we can only see if it works with some
tests & benchmarks.

- Branden


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About