Garbage collection
Garbage collection is an automated memory- or storage-management process that identifies objects or data no longer reachable or needed and reclaims or deletes them.
Troubleshooting Java, Second Edition
Garbage collection is the automatic runtime process of reclaiming memory occupied by objects that are no longer reachable.
- How it is used
- Uses GC behavior to investigate memory consumption, application slowdowns, heap exhaustion, and OutOfMemoryError failures.
- How deep it goes
- Explains reachability, leak symptoms, log interpretation, and diagnostic distinctions, while deferring root-cause confirmation to heap-dump analysis.
- Examples
- Uses VisualVM widgets, GC-log listings, heap-growth patterns, and persistent session references to illustrate diagnosis.
- What you can do after
- Diagnose/debug with VisualVM and GC logs by correlating pause times, frequency, heap reclamation, and CPU usage.
Read how Troubleshooting Java, Second Edition explains garbage collection →
100 Go Mistakes and How to Avoid Them
Garbage collection is automatic runtime management that identifies and reclaims memory no longer reachable by a program.
- How it is used
- Uses garbage collection to diagnose retained memory and guide Go performance tuning.
- How deep it goes
- Explains concurrent mark-and-sweep, pauses, scavenging, and GOGC triggers, then works through memory-retention and load scenarios.
- Examples
- Compares allocation measurements after shortening a slice or emptying a million-entry map, and contrasts steady with sudden user growth.
- What you can do after
- Diagnose/debug retained heap memory and operate/configure GOGC cautiously when collection frequency affects latency.
Read how 100 Go Mistakes and How to Avoid Them explains garbage collection →
.NET in Action, Second Edition
A garbage collector is a runtime component that identifies unreachable allocated memory and reclaims it for future allocations.
- How it is used
- Positions garbage collection as CoreCLR’s memory-management technique and a trade-off for real-time applications.
- How deep it goes
- Explains reference-based reclamation, allocation retry, stack and heap, and observable pauses without specifying a collector implementation.
- Examples
- Compares C++ and C# dynamic arrays and uses a PerfView GCStats table showing collection counts, pauses, and allocations.
- What you can do after
- Diagnose/debug with PerfView GCStats to inspect collection counts, total pauses, and allocations by generation.
Read how .NET in Action, Second Edition explains garbage collection →
Rust Servers, Services, and Apps
Garbage collection is automatic reclamation of memory occupied by objects that are no longer reachable by a program.
- How it is used
- Frames memory management as a language-design trade-off when evaluating Rust for web applications.
- How deep it goes
- Explains safety benefits and runtime costs, but stops short of describing garbage-collector algorithms or implementation internals.
- Examples
- Names Java, C#, Python, Ruby, and Go as garbage-collected languages, contrasting them with Rust, C, and C++.
- What you can do after
- Evaluate memory-management choices by weighing safety, performance, compute use, execution stalls, and non-memory resource handling.
Read how Rust Servers, Services, and Apps explains garbage collection →
Refactoring to Rust
Garbage collection is automatic reclamation of memory that is no longer reachable by a program.
- How it is used
- Contrasts automated reclamation with manual memory management when motivating Rust's reliability and performance model.
- How deep it goes
- Defines heap reclamation through reference checks and contrasts its safety and allocation trade-offs with manual management.
- Examples
- Uses a K welcome program with explicit free(name) calls to illustrate the burden of manual deallocation.
- What you can do after
- Evaluate whether automatic reclamation fits performance-sensitive software and explain Rust's alternative.
Go in Practice, Second Edition
A garbage collection system automatically identifies and reclaims memory that a program can no longer access.
- How it is used
- Uses automatic memory reclamation to reduce application-level memory-management work in Go services and system programs.
- How deep it goes
- Defines the runtime role and practical trade-offs, briefly mentions tuning, and stops short of explaining collector internals.
- Examples
- Compares Go with C, Java, Rust, and Zig, and demonstrates the GOGC environment variable as a tuning control.
- What you can do after
- Operate/configure Go programs with realistic expectations about collection overhead and the risks of disabling it.
Read how Go in Practice, Second Edition explains garbage collection →
Python Workout: 50 ten-minute exercises
Garbage collection is the automatic reclamation of memory occupied by objects that are no longer accessible.
- How it is used
- Frames memory management as background knowledge for optimization and understanding Python’s implementation.
- How deep it goes
- Explains reference-based lifetime through closures and __del__, but stops short of detailed collector internals or fine-grained control.
- Examples
- Uses retained closure state, a Python Tutor visualization, and a Person population-count exercise involving __del__.
- What you can do after
- Diagnose/debug with it by tracing references that keep objects and enclosing function state alive.
Read how Python Workout: 50 ten-minute exercises explains garbage collection →
Latency
A garbage collection algorithm is a procedure for identifying and reclaiming memory that a program no longer uses.
- How it is used
- Frames garbage collection as a managed-runtime source of latency variability and a target for low-latency optimization.
- How deep it goes
- Describes heap scanning, generations, bump-pointer allocation, incremental and parallel collection, pauseless designs, and tuning.
- Examples
- Uses generational regions, bump-the-pointer allocation, heap scanning, object movement, and incremental or parallel collection.
- What you can do after
- Diagnose collection-related tail-latency spikes by reducing fast-path allocations, selecting suitable algorithms, and tuning runtime parameters.
Web Components in Action
Garbage collection is automatic memory management that reclaims storage occupied by objects no longer reachable by a program.
- How it is used
- Connects Web Component removal from the DOM with cleanup and an opportunity for garbage collection.
- How deep it goes
- Defines reachability and demonstrates timer cleanup, without detailing garbage-collector algorithms.
- Examples
- Uses a removed custom element with a repeating timer or server query and disconnectedCallback cleanup.
- What you can do after
- Apply it via JavaScript by clearing component timers and resetting or nulling object links when elements leave the DOM.
Read how Web Components in Action explains garbage collection →
Related concepts
- Goused by · Go is a statically typed, compiled, garbage-collected programming language with built-in support for concurrency.
- Pythonincludes · Python is a high-level, general-purpose, dynamically typed programming language known for readable syntax and automatic memory management.
- CPUuses · A central processing unit (CPU) is a general-purpose processor that executes computer instructions and performs computational operations.
- JavaScriptincludes · JavaScript is a high-level, dynamically typed, multi-paradigm programming language standardized as ECMAScript and used for web and general-purpose programming.
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.








