Resource leak
A resource leak is the failure to release an acquired resource after it is no longer needed, leaving it occupied or unavailable for reuse.
100 C++ Mistakes and How to Avoid Them
A resource leak is a failure to release an acquired resource, leaving it allocated or unavailable for reuse.
- How it is used
- Uses resource leaks as a practical C++ correctness mistake involving exceptions, termination, ownership, and cleanup.
- How deep it goes
- Explains failure paths with code and cleanup traces, then stops short of redesigning legacy systems comprehensively.
- Examples
- Uses database connections, file-backed page text, dynamic grade arrays, and locally returned strings as failure examples.
- What you can do after
- Diagnose/debug with it by tracing ownership, destructor execution, exception paths, and cleanup responsibility.
Read how 100 C++ Mistakes and How to Avoid Them explains resource leak →
Functional Programming in Scala, Second Edition
A resource leak is failure to release an acquired resource, such as an open file handle, after it is no longer needed.
- How it is used
- Frames resource leaks as a practical failure mode in incremental file processing and a motivation for resource-safe abstractions.
- How deep it goes
- Explains normal and exceptional cleanup, then stops short of presenting a compiler-enforced resource-safety implementation.
- Examples
- Uses an imperative Scala file counter whose finally block closes the source after incremental iteration.
- What you can do after
- Diagnose leaks by identifying acquired resources whose cleanup is omitted or bypassed by exceptions.
Read how Functional Programming in Scala, Second Edition explains resource leak →
Kotlin in Action, 2E
A resource leak is the unintended retention or failure to release of resources such as threads, memory, or active concurrent tasks.
- How it is used
- Uses cancellation-safe cleanup and structured concurrency to prevent unreleased resources in concurrent Kotlin code.
- How deep it goes
- Explains the failure scenario and two cleanup mechanisms, but stops short of broader resource-management diagnostics.
- Examples
- Uses a cancellable DatabaseConnection coroutine, an explicit finally block, and the use function as contrasting cleanup examples.
- What you can do after
- Diagnose/debug with it by identifying cancellation paths and applying finally, use, or structured concurrency to guarantee cleanup.
Related concepts
- task cancellationaddressed by · Task cancellation is a request or mechanism for stopping an asynchronous or in-progress operation before it completes normally.
- deferaddressed by · Defer is a language feature that schedules an operation to execute when the surrounding function or scope exits, including during exceptional unwinding.
- resource cleanupaddressed by · Resource cleanup is the release of resources or restoration of state when an operation or scope ends or fails.
- resource acquisition is initializationaddressed by · Resource acquisition is initialization (RAII) is a resource-management pattern that ties resource ownership and release to the lifetime of an object or scope.
- copy assignment operatoraddressed by · A copy assignment operator is a C++ special member function that copies state from one object into an already existing object of a compatible type.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.


