So Python Essential Reference, 4 ed. says:
a = {}
b = {}
a['b'] = b
b['a'] = a
del a
del b
creates a memory leak, and the interpreter need a cycle detection algorithm to delete a and b. However, when I tried to work out how the refcount are, it seems to me that at the end, the refcounts for a and b both go to zero, so no cycle detection algorithms are required. Like:
a = {}
b = {}
refcounts: a = 1, b = 1
a['b'] = b
b['a'] = a
refcounts: a = 2, b = 2
del a
refcounts: b['a'] = 1, b = 1
del b
refcounts: a = 0, b = 0
What is wrong with my understanding of refcounts?