Can't I allocate at descontructor?
Jack
jckj33 at gmail.com
Fri Mar 5 19:29:42 UTC 2021
On Friday, 5 March 2021 at 05:42:03 UTC, evilrat wrote:
> On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote:
>> The following code returns a memory error. I did notice it did
>> happens whenever I did a memory allocation. Is this not
>> possible in the descontrutor? if so, why?
>>
>
> GC prohibits allocation during collection, since this dtor is
> likely called by GC this is what happens.
>
> If you REALLY need this just allocate using other mechanisms.
I didn't know that, it seems even if I use other allocation
mechanism there's no guarantee the deconstructor will be called
so it seems the native descontrutor will not be of help at all
More information about the Digitalmars-d-learn
mailing list