Gc/D_runtime prevents dangling pointers?

Steven Schveighoffer schveiguy at yahoo.com
Thu Jan 4 12:08:57 UTC 2018


On 1/4/18 6:50 AM, thedeemon wrote:
> On Thursday, 4 January 2018 at 11:05:25 UTC, tipdbmp wrote:

>> It seems that the '~=' operator "knows" that there's a reference to 
>> 'a's old memory and it keeps it around instead of freeing it.
> 
> It's just not its job to free that memory. That memory is freed later by 
> GC, when it's safe to do so.

Yeah, to further clarify, the array runtime has no idea who is looking 
at the memory. It doesn't "know" about references, it just relies on the 
GC to clean up the garbage if it actually is garbage.

-Steve


More information about the Digitalmars-d-learn mailing list