InvalidMemoryOperationError@(0)
Vladimir Panteleev via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Mon Nov 17 15:38:05 PST 2014
On Monday, 17 November 2014 at 22:40:36 UTC, Steven Schveighoffer
wrote:
> On 11/17/14 5:19 PM, Vladimir Panteleev wrote:
>> On Monday, 17 November 2014 at 16:40:18 UTC, ketmar via
>> Digitalmars-d-learn wrote:
>>> On Mon, 17 Nov 2014 15:41:25 +0000
>>> Andre via Digitalmars-d-learn
>>> <digitalmars-d-learn at puremagic.com> wrote:
>>>
>>>> ~this()
>>>> {
>>>> foreach(cp; this._columns)
>>>> {
>>>> }
>>>> }
>>> don't do that in destructors. `_columns` field can be already
>>> collected
>>> by GC.
>>
>> Last I checked, the GC finalizes all dead objects before
>> freeing them.
>
> The GC is not guaranteed to finalize them all before freeing
> them all.
>
> I would not count on that property -- even if it's currently
> true. Expect that any GC-allocated memory in your dtor is
> invalid except for the memory of the object itself.
That's disappointing because it makes destructors considerably
less useful. I think that at this point, this will probably
become a guarantee for compatibility with existing code.
More information about the Digitalmars-d-learn
mailing list