Can't I allocate at descontructor?

Jack jckj33 at gmail.com
Fri Mar 5 20:24:26 UTC 2021


On Friday, 5 March 2021 at 20:18:44 UTC, Max Haughton wrote:
> On Friday, 5 March 2021 at 20:13:54 UTC, Jack wrote:
>> On Friday, 5 March 2021 at 20:10:39 UTC, Max Haughton wrote:
>>> On Friday, 5 March 2021 at 20:03:58 UTC, Jack wrote:
>>>> On Friday, 5 March 2021 at 09:23:29 UTC, Mike Parker wrote:
>>>>> On Friday, 5 March 2021 at 05:31:38 UTC, Jack wrote:
>>>>>> [...]
>>>>>
>>>>> https://dlang.org/blog/2021/03/04/symphony-of-destruction-structs-classes-and-the-gc-part-one/
>>>>
>>>> thanks for such good article. So if the object was allocated 
>>>> on heap, there's no guarantee that the object's destrutor 
>>>> will be called at all? do destrutor allocate at stack are 
>>>> guarantee to be run?
>>>
>>> Destructors of structs on the stack will always run 
>>> deterministically.
>>
>> But the ones heap may never run at all, is that right?
>
> You can't rely on the garbage collector for deterministic 
> destruction, no.

Are there some kind of replacement or I have to make my own 
finalize-like method, once I determine somewhat the application 
no longer need those resources? aside from destructor for memory 
allocated on stack, what are uses for destrutors?


More information about the Digitalmars-d-learn mailing list