custom memory management

Dicebot public at dicebot.lv
Fri Feb 28 02:40:15 PST 2014


On Thursday, 27 February 2014 at 21:46:17 UTC, Simon Bürger wrote:
> Sadly, this is incorrect as well. Because if such an object is 
> collected by the gc, but the gc decides not to run the 
> destructor, the buffer will never be free'd.

I think you misiterpret the spec. If object is collected, 
destructor is guaranteed to run. But not all objects are 
guaranteed to be collected. For example, no collection happens at 
program termination.

So it is OK to release resources in destructor that will be 
reclaimed by OS at program termination anyway. List of such 
resources is OS-specific but heap memory tends to be there.


More information about the Digitalmars-d-learn mailing list