Question 0-6

Name and describe a disadvantage of using reference counting for garbage collection.

Solution

Garbage collection cannot identify unused objects involved in cyclic references. For example, even if two objects have instance variables referring to each other, and no other objects reference either of these objects, then the reference counts for both objects will be 1, and neither of them will be freed.

Back to Exam 0