by likeliv · 7y ago · 0 comments
Why is that? I would intuitively think it is the other way. (Is a malloc/free pair not cheaper than an allocation on the GC heap + collecting its garbages?)
It's always about details though. If a GC is faster than malloc/free, but your language doesn't tend to allocate much to begin with, the whole system can be faster even if malloc is slower. It always depends.
A GC that's integrated with a programming language can do much much better (different heaps for short and long lived allocations, for example).