Hacker News new | ask | show | jobs
by bheadmaster 1117 days ago
While reference counting is technically a method of collecting garbage, in modern parlance the phrase "garbage collector" is mainly used for systems capable of collecting garbage of an arbitrary reference graphs, which reference counting by itself cannot do (cyclic references).
2 comments

Anyone worried about tracing garbage collection is worried about unpredictable costs of automatic reclamation. Even naive reference counting has unbounded pathological cases like this, like an infinite list with only one reference that dies, which triggers a cascade of infinite free ops.

You can do some gymnastics like various types of deferrals to amortise the cost, but now you're getting into more sophisticated tracing-like runtime behaviour which has it's own unpredictability.

There's no free lunch. Better static analysis that can aggregate various allocation into arenas/regions seems like the only way to make this trade-off better.

General programming circles: “garbage collection” means only the “tracing” kind

PL circles: reference counting is also “garbage collection”

I sincerely doubt that those two groups are disjunct, or that they use the phrase "garbage collection" exclusively in the contexts you wrote.