Implementing Alternative Garbage Collector
Jacob Carlborg via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 2 23:36:51 PDT 2015
On 2015-09-02 22:13, Brandon Ragland wrote:
> On Wednesday, 2 September 2015 at 18:25:11 UTC, Jacob Carlborg wrote:
>> [1]
>> https://github.com/D-Programming-Language/druntime/blob/master/src/gcstub/gc.d
>>
>
> While that may be true, if the purpose was to ensure tracking and
> collection of objects / arrays created with the new expression, how
> would one do that without knowledge of the actual implementation and the
> interface?
>
> Same would go for slicing operations, which would be difficult to track.
>
> You'd have to pass a pointer to that new object onto the custom GC, or
> it will never see it. Quick way to have huge memory leaks...
I'm not sure I understand you're reply. You asked for the interface to
the GC, as far as I know the above link contains the interface for the
GC. That is, all the extern (C) functions.
As far as the "new" expression, technically it has nothing to do with
the GC. The "new" expression is lowered to a call to "_d_newclass" [1],
which in the current implementation then calls the GC.
I recommend you having a look in the "rt" package.
[1]
https://github.com/D-Programming-Language/druntime/blob/master/src/rt/lifetime.d#L71
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list