On Thursday, 9 October 2014 at 17:29:01 UTC, Dicebot wrote:
On Thursday, 9 October 2014 at 16:22:52 UTC, Andrei
Alexandrescu wrote:
To clarify: calling GC.free does remove the root, correct?
Not before it creates one. When I mean "avoid creating new GC
roots" I
mean "no GC activity at all other than extending existing
chunks"
That's interesting. So GC.malloc followed by GC.free does
actually affect things negatively?
Yes and quite notably so as GC.malloc can potentially trigger
collection. With concurrent GC collection is not a disaster but
it still affects the latency and should be avoided.
Is it just the potentially triggered collection, or is the actual
allocation+deallocation too expensive?
Because the effects of the former can of course be reduced
greatly by tweaking the GC to not collect every time the heap
needs to grow, at the cost of slightly more memory consumption.
If it's the latter, that would indicate that maybe a different
allocator with less overhead needs to be used.
Also let's note that extending existing chunks may result in
new allocations.
Yes. But as those chunks never get free'd it comes to O(1)
allocation count over process lifetime with most allocations
happening during program startup / warmup.
Hmm... but shouldn't this just as well apply to the temporary
allocations? After some warming up phase, the available space on
the heap should be large enough that all further temporary
allocations can be satisfied without growing the heap.