GC Destruction Order
Steven Schveighoffer via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue May 19 11:55:55 PDT 2015
On 5/19/15 2:37 PM, bitwise wrote:
> On Tue, 19 May 2015 14:19:30 -0400, Adam D. Ruppe
> <destructionator at gmail.com> wrote:
>
>> On Tuesday, 19 May 2015 at 18:15:06 UTC, bitwise wrote:
>>> Is this also true for D?
>>
>> Yes. The GC considers all the unreferenced memory dead at the same
>> time and may clean up the class and its members in any order.
>
> Ugh... I was really hoping D had something better up it's sleeve.
It's actually quite impossible for the GC to know what pointers are
"owning" pointers and what ones are not. And you could never have
ownership cycles.
You could use some version of malloc/free to do it. But you have to take
care of GC references inside that malloc'd block.
> I have heard about attempts to add precise GC to D though... would
> precise GC address this problem in some way?
No. Precise scanning just (potentially) cuts down on scanning time, and
avoids false pointers.
-Steve
More information about the Digitalmars-d-learn
mailing list