radical ideas about GC and ARC : need to be time driven?

via Digitalmars-d digitalmars-d at puremagic.com
Wed May 14 12:45:19 PDT 2014


On Wednesday, 14 May 2014 at 10:00:29 UTC, Ola Fosheim Grøstad 
wrote:
> On Wednesday, 14 May 2014 at 09:39:01 UTC, Marc Schütz wrote:
>> Well, it cannot be made 100% reliable by principle. That's 
>> just an inherent property of tracing GCs.
>
> I don't think this is true. Why is this an inherent property of 
> tracing GCs?

You're right, theoretically it's possible. I was only considering 
the situation with D:

- We have external code programmed in languages other than D, 
most prominently C and C++. These don't provide any type 
information, therefore the GC needs to handle their memory 
conservatively, which means there can be false pointers => no 
deterministic destruction.

- Variables on the stack and in registers. In theory, the 
compiler could generate that information, or existing debug 
information might be used, but that's complicated for the GC to 
handle and will probably have runtime costs. I guess it's 
unlikely to happen. And of course, when we call a C function, 
we're lost again.

- Untagged unions. The GC has no way to figure out which of the 
union fields is currently valid. If any of them is a pointer, it 
needs to treat them conservatively.

There are probably other things...


More information about the Digitalmars-d mailing list