[Issue 17881] Provide mechanism to preallocate memory from the GC

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Oct 6 20:42:40 UTC 2017


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

--- Comment #2 from Steven Schveighoffer <schveiguy at yahoo.com> ---
The use case is different than for GC.allocate.

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.

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.

--


More information about the Digitalmars-d-bugs mailing list