Greedy memory handling

monarch_dodra monarchdodra at gmail.com
Wed Sep 11 01:06:36 PDT 2013


I have a function that will *massively* benefit from having a 
persistent internal buffer it can re-use (and grow) from call to 
call, instead of re-allocating on every call.

What I don't want is either of:
1. To set a fixed limitation of size, if the user ends up making 
repeated calls to something larger to my fixed size.
2. For a single big call which will allocate a HUGE internal 
buffer that will consume all my memory.

What I need is some sort of lazy buffer. Basically, the 
allocation holds, but I don't want the to prevent the GC from 
collecting it if it deems it has gotten too big, or needs more 
memory.

Any idea on how to do something like that? Or literature?


More information about the Digitalmars-d-learn mailing list