Circular references

circular references are cleaned up the by the garbage collector but maybe not all the memory is given back to the OS, and it can take some time to clean them up.

import time

def create_pair():
    a = {'name' : 'Foo'}
    b = {'name' : 'Bar'}
    a['pair'] = b
    b['pair'] = a

for i in range(1, 30000000):

print("let's sleep now a bit")

but weakref might expedite the cleanup. See also the gc module and if I can show it