https://issues.dlang.org/show_bug.cgi?id=17881

--- Comment #3 from Andrei Alexandrescu <and...@erdani.com> ---
>The use case is different than for GC.allocate.

The semi-joke was this is all needed.

>I want to fill in a structure of nodes, I know I'm going to fill it in with 
>10,000 elements, so I'm going to allocate them all in a loop. But I don't want 
>the GC to keep the ENTIRE thing in memory if just one element is still pointed 
>at. And I don't want to run the GC constantly in my tight loop allocating each 
>node.

The solution is to prefill a freelist, then let go of the extra elements
remaining.

>Think of a tree constructor, or an AA constructor.

>Essentially it's the same as array.reserve, but for individual blocks instead 
>of a contiguous single block.

That's not the job of the allocator. It's the job of the user of the allocator.
The allocator gives you memory. You organize it as you find fit.

--

Reply via email to