logoalt Hacker News

Someonetoday at 4:35 PM1 replyview on HN

> I'd say GC is always the fastest to free objects within the main code path. Literally zero instructions

True, but reference counting or free need not be far behind. They can append the pointer being freed to a per-thread list (⇒ no locking needed) that a separate thread that does the actual freeing periodically claims and then iterates over to actually free the objects.

Disadvantage is that memory usage goes up a bit because the actual freeing is delayed, but that (likely) is less so than with a garbage collector.


Replies

thomashabets2today at 6:40 PM

Yup. I don't have to like GC to name a benefit of it. Which is good, because I don't like GC.

Java is a particularly good example of GC being bad[1], but I've also found it to be a tech debt generator in Go.

[1] A rant, which touches on GC stuff: https://blog.habets.se/2022/08/Java-a-fractal-of-bad-experim...