Prevent Garbage Collector

Adam D. Ruppe destructionator at gmail.com
Sat Jan 4 17:23:57 PST 2014


On Sunday, 5 January 2014 at 01:10:29 UTC, Jeroen Bollen wrote:
> Is there a way to tell it to not initialize it?

I'm not sure of any except using the primitives. You can malloc 
GC memory from GC.malloc (works the same way as C malloc, except 
you don't have to free it yourself; the GC does it). GC.malloc 
doesn't initialize the memory.

http://dlang.org/phobos/core_memory.html#malloc


I don't think there's a way to tell new not to zero it out 
though...

> Is it safe to use foreach on it if it isn't initialized?

Yeah, the contents will be random, but you are setting it anyway 
so that doesn't matter.


More information about the Digitalmars-d-learn mailing list