-nogc
Leandro Lucarella
llucax at gmail.com
Sat Apr 25 09:35:39 PDT 2009
Andrei Alexandrescu, el 23 de abril a las 13:27 me escribiste:
> Leandro Lucarella wrote:
> >And may I ask what it would happen if I do this with your "-nogc"
> >proposal?
> >class A
> >{
> > B b;
> >}
> >class B
> >{
> > A a;
> >}
> >A a = new A;
> >a.b = new B;
> >a.b.a = a;
> >? Wont this leak? Are you planning to make a backup tracing collector to
> >fix cycles maybe? Because I don't think using a naive reference counting
> >will avoid leaks as easy as you put it...
> >RC is not *that* simple.
>
> Oh I absolutely agree. In short, what happens depends on how Ref is
> implemented. In essence what I suggest is not (a simplified method of)
> reference counting, it's a hook that allows various
> allocation/collection strategies to be implemented by knowledgeable
> people (hint, hint) :o).
I think it would be awesome to have some kind of hooks to instrument
references read/writes so one can implement RC-based, partition-based
GC (like generational) or incremental collectors.
There were a proposal to make that some time ago by Frank Benoit:
http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D&article_id=35426
He proposed to add these hooks, with the default implementation being:
___ref_assign( void * trg, void * src ){ trg = src; }
void* ___ref_read( void * src ){ return src; }
I think you proposal of wrapping read/writes into a library defined type
is an improvement over the Frank's proposal.
(other proposals in that very same mail are as interesting as the
read/write instrumentation)
> I think WeakRef!T would also have to be part of the offering inside
> object_whatever.d. Then the example above can be fixed for the
> refcounting case by making one of the references weak.
I think WeakRef!T should be part of the GC, not object.d. The same goes
for Ref!T.
--
Leandro Lucarella (luca) | Blog colectivo: http://www.mazziblog.com.ar/blog/
----------------------------------------------------------------------------
GPG Key: 5F5A8D05 (F8CD F9A7 BF00 5431 4145 104C 949E BFB6 5F5A 8D05)
----------------------------------------------------------------------------
Hey you, with you ear against the wall
Waiting for someone to call out
Would you touch me?
More information about the Digitalmars-d
mailing list