Is a moving GC really needed?

Benji Smith dlanguage at benjismith.net
Thu Oct 5 18:14:17 PDT 2006


Marcio wrote:
>     I also don't see how a moving GC can live with the D features. I 
> know that having a non-moving GC can have people produce code that is 
> not portable across compiler implementations.

In C#, a block of code can't create or access pointers unless it uses 
the "unsafe" keyword. And, any reference types within the method body 
have to be specifically pinned at one memory location (using a "fixed" 
block) whenever a pointer might be accessing that memory.

It works really well. The vast majority of my code uses the default GC 
behavior, but every once in a while, I need to do some pointer 
manipulation, and I temporarily tell the garbage collector to refrain 
from moving my objects.

I think a similar system could work in D.

--Benji Smith



More information about the Digitalmars-d mailing list