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

Manfred Nowak svv1999 at
Wed Feb 8 05:30:40 PST 2012

Marco Leise wrote:

> In D we allocate memory through the GC
> Let's assume, we have a program that allocates some buffers in
> advance, that it may not use fully.
> there is really no alternative to calloc.

calloc implements a strategie for allocating memory. If this strategy 
is usefull for parts of a program, then the GC should be informed 
from the code and be capable to adapt its behavior to the requested 

This seems necessary because there is not only the null pattern to 
initialize allocated memory. 

According to your OP the request for allocating memory can be 
disjoint partitioned into three:
a) memory that is guaranteed to be used
b) memory that is guaranteed not to be used and
c) memory that might be used.

For the case that a + b exceeds available memory, should the coder 
predeclare a strategy, i.e. should the GC signal out of memory on 
request of the memory or should the GC wait until that sum reaches 
some deadline?


More information about the Digitalmars-d mailing list