Mem Mgmt: With & Without the GC

Cauterite via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Aug 21 09:38:09 PDT 2016


On Sunday, 21 August 2016 at 16:14:53 UTC, Zane 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?

I can answer this at least,
If you don't want the GC to ever collect the object itself, 
here's the best way:
Allocate the object with a non-GC allocator (such as std.c.malloc 
), then use `emplace` to construct the object in that memory ( 
http://dlang.org/phobos/std_conv.html#.emplace ).




More information about the Digitalmars-d-learn mailing list