|
|
|
|
|
by cesarb
1885 days ago
|
|
> In what sense it is deterministic? In at least two senses: 1. Memory usage: with reference counting, at any given moment, the amount of memory used is the minimum necessary for all live references. 2. Timing: with reference counting, the only moment when memory will be released (and their corresponding destructors called) is when a reference count is decremented. > Any refcount decrement may or may not be the last one and that may or may not cause a huge graph of objects being free()d which (even without destructors) takes unpredictable amount of time. That's actually predictable: it will always happen precisely at the last refcount decrement for that object, and will release only that object and other objects owned exclusively by that object, and nothing else. The size of that "huge graph of objects" is bounded, which makes the time taken to release it predictable. |
|
By the same line of reasoning, since the total size of the heap is bounded, it makes the time taken to sweep through it predictable.