3 ms·
Not really. Sure it adds some overhead but it's well optimized and not overly significant, especially for incremental collections. It can even pay for itself by
by daxfohl 3y ago
Not really. Sure it adds some overhead but it's well optimized and not overly significant, especially for incremental collections. It can even pay for itself by defragging your memory, making subsequent allocations cheaper. The big problem with GC is the pauses it causes when doing full "stop the world" collections, which can be noticeable in animations, or even on server-side in high-volume latency-sensitive services. But there are strategies you can use to reduce or eliminate the need for those if you're willing to put in the effort (beyond the scope of this comment).
Note that pauses _can_ happen in non-GC languages too, if you have to delete something that references a bunch of other stuff that you have to recursively delete as well, though in the real world this is not very common.