Skip to content

Comment on Real-Time Garbage Collection Is Realparent

Comments

Well, if you have data that can be referenced from more than one spot (for example, an object pointer that is a member of multiple lists), you need avoid calling free until the last reference is gone. One way to track that is to use an incrementing and decrementing reference counter, but then you end up leaking memory as soon as you get cyclical references. A garbage collector solves the problem of cyclical references.

In some cases a garbage collector can turn out to be more efficient too, since there is no need to spend time carefully managing reference counts! :)

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.