Transitioning to a type aware Garbage Collector
Kyle Furlong
kylefurlong at gmail.com
Mon Jan 22 14:46:21 PST 2007
Walter Bright wrote:
> To improve GC performance, we need to transition to a GC that is aware
> of the types of what it is allocating.
>
> So problems can happen if the type of allocated memory is changed after
> it is allocated, via casting. The way to avoid this is to allocate as
> void[] memory that will be cast, as in:
>
> struct Foo { ... };
> Foo[] f;
>
> p = new void[100];
> f = cast(Foo[])p; // ok
> byte[] b = cast(byte[])p;
> f = cast(Foo[])b; // ok, GC still regards memory as void[]
>
> rather than:
>
> p = new byte[100];
> f = cast(Foo[])p; // will likely eventually corrupt memory
>
> The GC will regard void[] as a chunk of memory containing arbitrary data
> of arbitrary types, and so will treat it conservatively.
>
> In general, regard memory allocated by the GC as anything other than
> void[] as being *strongly typed*.
As this move happens, some interesting possibilities open for more
efficient garbage collection. One innovation is CBGC, connectivity based
garbage collection.
The paper describing this class of algorithm can be found here:
http://portal.acm.org/citation.cfm?id=949337&coll=GUIDE&dl=ACM&CFID=6079566&CFTOKEN=11708043
I have done an extensive review of the literature regarding garbage
collection in compiled languages (and others) and this seems to me to be
the best bet for a modern GC for D.
Thoughts?
More information about the Digitalmars-d-announce
mailing list