How to save RAM in D programs (on zero initialized buffers): Reloaded

Marco Leise Marco.Leise at gmx.de
Tue Feb 7 20:32:08 PST 2012


Am 07.02.2012, 22:15 Uhr, schrieb Iain Buclaw <ibuclaw at ubuntu.com>:

>>   o  zero out a memory block     <---------- !!!

> What about these functions?
>
>
> import std.array;
>
> byte[][ALLOCS] a, b;
>
> writeln("** uninitializedArray!(ubyte[])(1024*1024)");
> foreach(i; 0 .. ALLOCS) b[i] = uninitializedArray!(ubyte[])(1024 * 1024);
> prev = print_ressources(&prev);
>
> writeln("** minimallyInitializedArray!(ubyte[])(1024*1024)");
> foreach(i; 0 .. ALLOCS) c[i] = minimallyInitializedArray!(ubyte[])(1024  
> * 1024);
> prev = print_ressources(&prev);
>
>
>
> Regards
>

Yeah I know these and used them, only to find out the program I am porting  
relies on the data beeing zeroed out (it is a certain type of compression  
utility). It's a shame to see the C version get away with a low memory  
footprint _and_ zero initialized buffers. I'll just copy the 'Array' class  
 from the original then, that uses calloc and free.


More information about the Digitalmars-d mailing list