Memory leak
A memory leak is the unintended retention of allocated memory that is no longer needed, preventing it from being reclaimed for reuse.
Fast by Default
A failure to release memory that is no longer needed, causing memory usage to grow over time.
- How it is used
- Detects unbounded memory growth before it becomes paging, app termination, service failure, or user-visible slowness.
- How deep it goes
- Explains retention patterns, budget checkpoints, snapshot comparison, and platform profilers rather than garbage-collector internals.
- Examples
- Uses desktop event handlers and undo stacks, repeated backend requests, destroyed mobile screens, and detached Electron elements.
- What you can do after
- Diagnose/debug with snapshot comparisons, lifecycle checks, budgets, and platform-specific memory profilers.
Troubleshooting Java, Second Edition
A memory leak is a software defect in which allocated memory remains unreleased after it is no longer needed.
- How it is used
- Guides profiling investigations of abnormal memory consumption before slowness, heap exhaustion, or application failure.
- How deep it goes
- Explains retained references, GC symptoms, diagnostic tools, and a failing Java example, but defers exact retention analysis to heap dumps.
- Examples
- Uses an unbounded static Java list, VisualVM memory graphs, GC-log entries, and lingering session references as diagnostic examples.
- What you can do after
- Diagnose suspected leaks with VisualVM and heap-usage logs, distinguish them from insufficient memory, and identify retained references with a heap dump.
Read how Troubleshooting Java, Second Edition explains memory leak →
JavaScript in Depth
A condition in which memory remains retained or allocated despite no longer being needed by a program.
- How it is used
- Frames rising process memory as a retention problem to distinguish from temporary garbage-collection pressure.
- How deep it goes
- Works through a four-step diagnostic flow and V8 closure retention, while detailing only the flow’s first two steps.
- Examples
- Uses a closure retaining a million-character string, an event listener, and rising post-collection heap troughs.
- What you can do after
- Diagnose/debug with it by checking memory baselines, separating leaks from pressure, and removing references that retain unneeded objects.
100 C++ Mistakes and How to Avoid Them
A memory leak is a failure to release dynamically allocated storage after it is no longer accessible or needed.
- How it is used
- Uses memory leaks to motivate disciplined resource management in C++ classes and polymorphic deletion.
- How deep it goes
- Explains allocation, destruction, and assignment failures through examples and corrections, including undefined behavior from mismatched operations and nonvirtual destruction.
- Examples
- Uses a malloc-allocated Buffer and a Square deleted through a Shape pointer to illustrate missed cleanup.
- What you can do after
- Evaluate C++ cleanup paths for missing releases, mismatched allocation, and nonvirtual base destructors.
Read how 100 C++ Mistakes and How to Avoid Them explains memory leak →
Troubleshooting Java: Read, debug, and optimize JVM applications
A software problem in which an application fails to deallocate data it no longer needs, causing free memory to diminish over time.
- How it is used
- Uses memory leaks as a resource-consumption problem to investigate during execution or after an application crash.
- How deep it goes
- Explains retained references and memory graphs through a Java example, while directing root-cause investigation to heap dumps.
- Examples
- Demonstrates a Java loop that continually adds Cat objects to a static list and eventually exhausts heap space.
- What you can do after
- Diagnose/debug with VisualVM by recognizing suspicious memory growth and use a heap dump for further root-cause investigation.
Read how Troubleshooting Java: Read, debug, and optimize JVM applications explains memory leak →
100 Go Mistakes and How to Avoid Them
A memory leak is a failure to release memory or another managed resource after it is no longer needed.
- How it is used
- Diagnoses unnecessary resource retention in Go slices, substrings, and timeout loops.
- How deep it goes
- Traces retained backing data and timer resources, then contrasts copying, clearing references, cancellation, and timer reuse.
- Examples
- Uses a slice of byte-containing structs, UUIDs extracted from log messages, and a channel consumer with an hourly timeout.
- What you can do after
- Diagnose/debug retained memory by tracing references and selecting a contextual remedy for slices, substrings, or timeout loops.
Read how 100 Go Mistakes and How to Avoid Them explains memory leak →
Acing the Frontend Interview
A memory leak is unintended continued retention of memory by objects or resources that an application no longer needs.
- How it is used
- Frames memory leaks as an interview concern linking closure behavior, garbage collection, event listeners, and long-running application performance.
- How deep it goes
- Explains closure retention, garbage-collection reachability, and listener cleanup, while deferring detailed profiling and scalable optimization.
- Examples
- Uses a closure-based counter, a large captured array in a click handler, and explicit data clearing and listener removal.
- What you can do after
- Diagnose closure-based retention and apply event-listener cleanup to reduce unnecessary memory consumption.
Read how Acing the Frontend Interview explains memory leak →
.NET in Action, Second Edition
A memory leak is a condition in which memory remains allocated or unreachable despite no longer being needed by a program.
- How it is used
- Frames memory leaks as a reliability risk of explicit heap management when comparing C++ with .NET garbage collection.
- How deep it goes
- Defines a leak through unfreed allocation and a lost pointer, without developing a leak-diagnosis procedure.
- Examples
- Uses a C++ dynamically allocated integer array and its C# array counterpart.
- What you can do after
- Diagnose/debug with it by recognizing when allocated C++ array memory is not freed before its pointer is lost.
Read how .NET in Action, Second Edition explains memory leak →
Idiomatic Rust
A memory leak is a failure to release dynamically allocated memory after it is no longer reachable or needed.
- How it is used
- Diagnoses unreleased heap allocations and motivates automatic cleanup through C++ object lifetime management.
- How deep it goes
- Traces malloc, pointer scope, early returns, and free, then contrasts them with C++ cleanup objects.
- Examples
- Uses malloc(sizeof(int)), a failing fopen branch, free(a), shared_ptr<int>, and ifstream.
- What you can do after
- Diagnose leaks by matching every heap allocation with cleanup across all return paths.
Also covered in
- Designing Deep Learning Systems: A guide for software engineers
- The Art of Code
- Kubernetes for Developers
- Secrets of the JavaScript Ninja, Third EditionIn early access (MEAP)
- Build AI-Enhanced Web Apps
- React Quickly, Second Edition
- Memory Safe C++In early access (MEAP)
- Modern C
- Modern C, Third Edition
- Writing for Developers: Blogs that get read
What to know first
- garbage collectionGarbage collection is an automated process that identifies and reclaims or removes memory, data, or other items no longer reachable or needed by a system.
- CPUA central processing unit (CPU) is a computer processor that executes program instructions and performs general-purpose computational operations.
- memoryMemory is a storage capability or mechanism for retaining information or computational state for later access or use.
Related concepts
- WeakMapaddressed by · WeakMap is a JavaScript collection that associates values with weakly held object keys, which do not prevent garbage collection and whose entries cannot be enumerated.
- allocation pressurecontrasts with · Allocation pressure is the rate or volume of memory allocation imposed on a runtime during program execution.
- Memcheckaddressed by · Memcheck is Valgrind's dynamic analysis tool for detecting memory errors and memory leaks.
- memory errorproduces · An out-of-memory error is a runtime failure that occurs when a process or system cannot obtain enough memory for a requested allocation or operation.
Questions about memory leak
What is memory leak?
A memory leak is the unintended retention of allocated memory that is no longer needed, preventing it from being reclaimed for reuse.
Which Manning books explain memory leak?
Fast by Default, Troubleshooting Java, Second Edition, JavaScript in Depth, 100 C++ Mistakes and How to Avoid Them, Troubleshooting Java: Read, debug, and optimize JVM applications, 100 Go Mistakes and How to Avoid Them, Acing the Frontend Interview, .NET in Action, Second Edition and 1 more.
What should I know before learning memory leak?
Manning books that teach memory leak usually introduce garbage collection, CPU, Java and memory first.
What is the difference between memory leak and allocation pressure?
A memory leak is the unintended retention of allocated memory that is no longer needed, preventing it from being reclaimed for reuse. Allocation pressure is the rate or volume of memory allocation imposed on a runtime during program execution.
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.








