2 ms·
It's not about the memory model. GC will take care of all kinds of resources. The problem is that different kinds of resources are, well, different. Part of th
by int_19h 6y ago
It's not about the memory model. GC will take care of all kinds of resources.
The problem is that different kinds of resources are, well, different. Part of the confusion is when documentation talks about "scarce" resources, without explaining what this really means (or whether it's really the best word to describe the difference), so then people make assumptions, often incorrect ones.
With memory, if you leave it around for GC to eventually get to it, the only side effect is an increase in memory pressure.
But with open files, there are a lot of other observable side effects of keeping the handle open, aside from running out of file descriptors. For example, it would place significant limitations on the ability to open the same file by a different process, or by unrelated code in the same process. And on Windows, you wouldn't be able to delete such a file, or any directory that contains it directly or indirectly.