1.

How does reference counting deal with objects that are memory allocated in context to OS? When does it fail to reclaim objects?

Answer»

Every object GAINS a count of how many times it has been referred to in the context of reference counting. Every TIME a reference to that item is made, the count is increased. A reference's value is also decremented every time it is deleted. This operation continues until the reference count reaches zero. When an object's reference count reaches 0, the object can be RECOVERED. By preserving a count in each object, reference counting systems may do AUTONOMOUS memory management. Any object without a reference count can be regarded as "dead," and its memory can be recovered.

In the situation of cyclic references, the reference counting method may fail to reclaim objects. There are no concrete solutions to this problem, therefore it is usually recommended to design architecture without circular references.



Discussion

No Comment Found