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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 11 18:21:21 UTC 2017


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

safety0ff.bugz <safety0ff.bugz at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |safety0ff.bugz at gmail.com

--- Comment #7 from safety0ff.bugz <safety0ff.bugz at gmail.com> ---
(In reply to Steven Schveighoffer from comment #6)
> > If we add thread local free-lists to the GC, the overhead of allocating
> > these from the GC instead of caching them in the AA would be rather small.
> 
> Agreed, I think keeping the lists inside the GC is the most useful, and does
> not expose any implementation details to the user.

I think this is the only sane way of doing it. i.e. without over constraining
the GC implementation or exposing the user to implementation details.

I think the API should obviously should have the size of the elements as a
separate arguments and provide as much information as malloc e.g.:
GC.preload(size_t num, size_t size, uint ba = 0, const TypeInfo ti = null)

Otherwise it relies on hope that the GC will pull from the same pool.

--


More information about the Digitalmars-d-bugs mailing list