Reference counting manages memory by tracking how many active references point to each object. It increments when a reference is added, decrements when one is removed, and deletes the object when the count reaches zero. section 1.5
In CPython, reference counting helps explain the global interpreter lock: simultaneous reference-count updates could produce an incorrect count, so the operation must be protected from competing threads. section 1.5
A simultaneous update
If two threads increment the same reference count at once, both may read the same old value and write back the same incremented value. The expected count of two becomes one, creating a race condition. section 1.5
Figure 1.6 A race condition where two threads try to increment a reference count simultaneously. Instead of an expected count of two, we get one.
Visualizes two threads attempting to increment one reference count simultaneously and losing one update. section 1.5



