4 ms·
A language can introduce the concept of a strong and weak reference or use a cycle detection algorithm.
by hgs3 5y ago
A language can introduce the concept of a strong and weak reference or use a cycle detection algorithm.
- deepsun 5y agoWouldn't cycle detection algorithm basically become a GC under a different name?
- hgs3 5y agoRC is GC and whether a cycle detection algorithm uses tracing depends upon the algorithm itself. Unlike traditional tracing, a cycle detection algorithm can leverage knowledge of the reference counter which opens new possibilities. In fact, cycle detection doesn't necessarily need to be run at all - only in the ambiguous cases where RC alone isn't enough. When a code path does necessitate cycle detection, the algorithm could run immediately and, depending upon the nature of the cycle/how localized it is, the runtime could cache the knowledge for next time. Even where it must always be run, the pauses are smaller and deterministic which means it avoids the long/unpredictable/sporadic pause times tracing collectors are infamous for.