Prevent Garbage Collector

Jeroen Bollen jbinero at gmail.com
Sat Jan 4 17:10:27 PST 2014


On Sunday, 5 January 2014 at 00:28:00 UTC, Adam D. Ruppe wrote:
> On Sunday, 5 January 2014 at 00:17:12 UTC, Jeroen Bollen wrote:
>> Also a somewhat unrelated question, variables in D get 
>> initialized by default, do they also when you define them 
>> right after? Something like:
>
> Maybe. Logically, it is always initialized unless you 
> explicitly tell it not to ( = void on declarations, not sure 
> about making new return uniniialized memory), but the optimizer 
> might see that the initalization is useless and skip it.

The 'might' here is worrying, as the array will be huge and it's 
really costly to initialize it twice. Is there a way to tell it 
to not initialize it? Is it safe to use foreach on it if it isn't 
initialized?


More information about the Digitalmars-d-learn mailing list