However, this isn't really a good test. Since the file objects created are not part of any circular structure, they are freed by the refcounting. Thus it doesn't matter if close() frees the fd or not, the object will be deallocated immediately afterwards. No gc() is needed.