want to confirm: gc will not free a non-gc-allocated field of a gc-allocated object?

Guillaume Piolat first.last at gmail.com
Mon Jun 6 22:26:35 UTC 2022


On Monday, 6 June 2022 at 22:24:45 UTC, Guillaume Piolat wrote:
>
> My understanding is that while scanning, the GC will see the 
> data.ptr pointer, but will not scan the area it points to since 
> it's not in a GC range (the runtime can distinguish managed 
> pointer and other pointers).
>
> After scanning, when obj is non-reachable, the GC will destroy 
> it but that won't lead to a reclaim of data.ptr since it knows 
> it doesn't own that.

In D, the ownership of slice is purely determined by the memory 
area it points to.
If it points into GC memory then it's a GC slice.


More information about the Digitalmars-d-learn mailing list