← Back to context

Comment by foldr

5 months ago

It is not correct to think of garbage collection as malloc + free + GC overhead. For example, allocating memory is much faster in many GC designs than a call to malloc (it can just be a pointer bump on the fast path).

I think you are assuming that a garbage collector calls malloc and free and then does a bunch of additional work on top of that to keep track of memory allocations, but that's not really how it works.