|
|
|
|
|
by 0x0
4759 days ago
|
|
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! :) |
|