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.