A question/suggestion regarding the GC

Christopher Wright dhasenan at gmail.com
Sun Sep 21 14:05:19 PDT 2008


Jarrett Billingsley wrote:
> On Sat, Sep 20, 2008 at 4:58 PM, bearophile <bearophileHUGS at lycos.com> wrote:
>> I hope to see this, but I think there are some people that like D that think that having two different GCs running at the same time is too much complext, etc.
> 
> Let me guess: in that sentence, "some people" means "me" (you).
> 
> Actually it wouldn't require having 2 GCs at all, as long as you
> forewent the possibility of having a moving GC.  More or less SafeD
> would be memory-safe, and so this theoretical "almost-precise" GC
> _would_ be precise for SafeD code, and would only be imprecise when
> dealing with non-SafeD code.  It would all be covered by one GC,
> though.
> 
> If your _entire_ program were in SafeD, however, you could come up
> with a new GC that could do heap compaction and the like.

I would prefer to avoid multiple GCs in one application. For one thing, 
fullCollect would either have to scan twice or only collect stuff from 
one GC. Probably the former; due to the use of SIGUSR1/SIGUSR2 on Unix, 
it'd be difficult to have two GCs run separately in one process without 
some sort of controlling GC.

Anyway, two GCs running at once is guaranteed to be inefficient.

You could usefully come up with a pluggable GC that does much of the 
scanning and so forth, maybe. But I wouldn't hold my breath.

Still, heap compaction doesn't require SafeD. It requires compiler 
support, but not language support. The only thing that you can't do 
without language support is a precise GC that handles unions. (Maybe you 
could do that as well, if the compiler inserted a discriminator value.) 
You could accomplish this with C or C++ or D.


More information about the Digitalmars-d-learn mailing list