resource leak
A file, socket, timer or other system resource that a program opened and never closed.
Leaked descriptors and sockets accumulate until new connections or files fail with EMFILE.
In more detail
Each leak holds a file descriptor or memory, and enough of them exhaust the process's limits. Closing resources in finally blocks, or with using declarations, prevents most leaks.
Related terms
- file descriptor — A small number the operating system gives a process for each open file, socket or pipe, used in every later read or write.
- EMFILE — The error code meaning a process has hit its limit on open file descriptors, printed as "too many open files".
- teardown — Removing or releasing everything that was set up for a piece of work, from a test's open connections to a whole temporary environment, once it is no longer needed.
Taught in
- Close Phase & Signal Dispatch: Sockets & Teardown — Node.js Internals & Backend Services
- Stream Pipelines: pipeline, AbortSignal & Teardown — Node.js Internals & Backend Services
- Asynchronous File I/O: node:fs/promises & Handles — Node.js Internals & Backend Services