<div dir="ltr"><div>>> (PS: An alternative scheme would be to introduce a reference counter
f.refcnt,</div><div>which is increased in Files.Old and decreased in Files.Close,
which would in</div><div>addition remove a file descriptor from the list if the
counter reaches 0. But that</div><div>would make things more complicated).</div><div><br></div><div>I'm afraid the reference counter will not solve the issue, because, firstly, one is</div><div>not asked to call Files.Close, one can just leave the file as is, and in this case the</div><div>file descriptor will still need to be collected if there are no references to it. And,</div><div>secondly, Files.Close does not actually "close" the file, but it just flushes the</div><div>buffers, and after Files.Close the file can be still read from and written to.</div><div>More calls to Files.Close can be done later. "Close" means "close the buffers".<br></div></div>