Program crash: GC destroys an object unexpectedly
Steven Schveighoffer
schveiguy at gmail.com
Wed Sep 22 12:26:53 UTC 2021
On 9/22/21 8:22 AM, eugene wrote:
> On Wednesday, 22 September 2021 at 11:44:16 UTC, Steven Schveighoffer
> wrote:
>> Once it's on the stack, the GC can see it for the full run of `main`.
>> This is why this case is different.
>>
>> Note that Java is even more aggressive, and might *still* collect it,
>> because it could legitimately set `stopper` to null after the last use
>> to signify that it's no longer needed.
>
> And it follows that programming in GC-supporting languages
> *may* be harder than in languages with manual memory
> management, right?
>
Only when interfacing with C ;) Which admittedly is a stated goal for D.
It's telling that I've been using D for 14 years and never had or seen
this problem.
-Steve
More information about the Digitalmars-d-learn
mailing list