GC: memory collected but destructors not called
via Digitalmars-d
digitalmars-d at puremagic.com
Wed Nov 12 01:29:20 PST 2014
On Wednesday, 12 November 2014 at 04:59:33 UTC, Shachar Shemesh
wrote:
> On 10/11/14 16:19, Steven Schveighoffer wrote:
>>
>> Only classes call dtors from the GC. Structs do not. There are
>> many
>> hairy issues with structs calling dtors from GC. Most struct
>> dtors
>> expect to be called synchronously, and are not expecting to
>> deal with
>> multithreading issues.
>>
>> Note that structs inside classes WILL call dtors.
>
> How is this any different? If one should not be allowed, how is
> the other okay?
Supposedly, a struct destructor will only access resources that
the struct itself manages. As long as that's the case, it will be
safe. In practice, there's still a lot that can go wrong.
More information about the Digitalmars-d
mailing list