On Saturday, 12 September 2015 at 06:23:12 UTC, Jonathan M Davis wrote:
Aside from the few classes in Phobos, its GC usage is almost entirely restricted to when it allocates arrays or when it has to allocate a closure for a delegate, which can happen in some cases when passing predicates to range-based algorithms. Avoiding functions that need to allocate arrays avoids that source of allocation, and using functors or function pointers as predicates avoids having to allocate closures. So, you _can_ end up with GC allocations accidentally in Phobos if you're not careful, but on the whole, the assertion that Phobos uses the GC heavily is FUD - or at least a misunderstanding. But as we make more of the functions use lazy ranges rather than arrays (particularly with regards to strings), and we make more of the code @nogc, it becomes even clearer that the GC isn't involved. Also, improvements to how lambdas are handled should reduce how often closures have to be allocated for them.

Thank you for this. How large is the allocation for closure for a delegate? Just a pair of pointers?

On Saturday, 12 September 2015 at 13:42:44 UTC, Prudence wrote:
I don't think it's that simple.

Saying that it doesn't use it most of the time is not an answer/solution. Using it at all is a problem because one doesn't know when and where. I realize there is a switch now(-vgc), and maybe that is the solution, but you say "well, phobos only uses 0.01% on the GC", yet since you either don't, can't, or won't know where that is, then it might as well be 100% if you would like to potentially get off the GC one day.

It's like playing Russian roulette. It doesn't matter if only 1/6 times will kill you. It's totally different than 0/6.

But if you hardly use the GC, how long is it really going to take to run?

Reply via email to