A good way to leak your file descriptors is to mix up destructors (as in C++) with finalizers (in systems with garbage collection). The common C++ idiom is resource acquisition is initialisation (aka RAII):

{
  ifstream in(filename);
  // ... do stuff with in ...
}               // file is closed here by in's destructor
In a system with (only) garbage collection, in might not be destroyed until the system runs out of memory.

So if your system runs out of file descriptors before it runs out of memory, you're leaking fd's.

faulty = F = fear and loathing

fd leak /F-D leek/ n.

A kind of programming bug analogous to a core leak, in which a program fails to close file descriptors (`fd's) after file operations are completed, and thus eventually runs out of them. See leak.

--The Jargon File version 4.3.1, ed. ESR, this entry manually entered by rootbeer277.

Log in or registerto write something here or to contact authors.