How to use destroy and free.
H. S. Teoh
hsteoh at quickfur.ath.cx
Tue May 3 15:12:41 UTC 2022
On Tue, May 03, 2022 at 02:57:46PM +0000, Alain De Vos via Digitalmars-d-learn wrote:
> Note, It's not i'm against GC. But my preference is to use builtin
> types and libraries if possible,
> But at the same time be able to be sure memory is given free when a
> variable is going out of scope.
> It seems not easy to combine the two with a GC which does his best
> effort but as he likes or not.
If your objects have a well-defined lifetime and you want to control
when they get freed, just use malloc/free or equivalents (use emplace to
initialize the object in custom-allocated memory). Don't use the GC.
Using the GC means you relinquish control over when (and in what order)
your objects get freed.
T
--
There's light at the end of the tunnel. It's the oncoming train.
More information about the Digitalmars-d-learn
mailing list