August 22, 2016 Re: Mem Mgmt: With & Without the GC | ||||
---|---|---|---|---|
| ||||
Posted in reply to Guillaume Piolat | On Sunday, 21 August 2016 at 19:30:51 UTC, Guillaume Piolat wrote: >> 5) Is there a way to do simple heap allocation with 'new' while ensuring the GC doesn't deallocate until I want it to? > > Keep a reference somewhere reachable (by default: stack, heap, globals: everything is reachable and scanned). > Or just tell the GC directly not to collect it via GC.addRoot: https://dlang.org/phobos/core_memory.html#.GC.addRoot |
Copyright © 1999-2021 by the D Language Foundation