liveBook · Manning

Garbage collection

Also called gc

Garbage collection is an automated process that identifies and reclaims or removes memory, data, or other items no longer reachable or needed by a system.

How 12 Manning books explain it

JavaScript in Depth

A garbage collector is a runtime component that automatically identifies and reclaims memory occupied by unreachable objects.

How it is used
Explains latency spikes and memory pressure by relating collection work to allocation and object lifetime.
How deep it goes
Traces reachability and V8 promotion into old-generation collection work, while noting that ECMAScript leaves collector design unspecified.
Examples
Uses a timer retaining a request body, a stream retaining chunks, and heap-usage patterns.
What you can do after
Diagnose/debug collection pressure with --trace-gc and heap measurements, then shorten unnecessary reachability paths.

Read how JavaScript in Depth explains garbage collection →

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 heap memory and inform Go application optimization.
How deep it goes
Explains concurrent mark-and-sweep, pauses, scavenging, heap-growth triggers, and tuning trade-offs.
Examples
Demonstrates retention with a two-element slice and a deleted-entry map, and compares steady and sudden user-load growth.
What you can do after
Diagnose retained allocations and configure GOGC with attention to collection frequency and load.

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 →

Acing the Frontend Interview

Garbage collection is automatic reclamation of memory occupied by objects that are no longer reachable by a program.

How it is used
Uses garbage collection to explain closure lifetime, memory-leak prevention, and interview readiness.
How deep it goes
Explains closure and event-listener retention with cleanup examples, but stops short of detailed collector internals or profiling procedures.
Examples
Uses a counter closure, a click handler retaining a large array, and listener removal with memory clearing.
What you can do after
Diagnose/debug with it: identify retained closure references and remove listeners to prevent memory leaks.

Read how Acing the Frontend Interview 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.

Read how Refactoring to Rust explains garbage collection →

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 →

High Performance Unity Game Development

The automatic process of identifying and reclaiming memory occupied by unreachable objects.

How it is used
Frames garbage collection as a source of unpredictable gameplay slowdowns when heap allocations accumulate.
How deep it goes
Explains marking, delayed reclamation, CPU cost, and non-compaction, but stops short of collector implementation details.
Examples
Uses destroyed and reinstantiated enemy GameObjects plus a per-frame array-allocation loop measured in the Unity Profiler.
What you can do after
Diagnose/debug with it using Unity Profiler GC-allocation readings, then reduce gameplay allocations or move collection to less disruptive moments.

Read how High Performance Unity Game Development 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.

Read how Latency explains garbage collection →

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 →

Also covered in

What to know first

Related concepts

Questions about garbage collection

What is garbage collection?

Garbage collection is an automated process that identifies and reclaims or removes memory, data, or other items no longer reachable or needed by a system.

Which Manning books explain garbage collection?

JavaScript in Depth, Troubleshooting Java, Second Edition, 100 Go Mistakes and How to Avoid Them, .NET in Action, Second Edition, Rust Servers, Services, and Apps, Acing the Frontend Interview, Refactoring to Rust, Go in Practice, Second Edition and 4 more.

What should I know before learning garbage collection?

Manning books that teach garbage collection usually introduce memory, CPU, Java and performance first.

What kinds of garbage collection are there?

Kinds of garbage collection include JavaScript, Julia, per-process garbage collection and Python.

What is garbage collection also called?

Garbage collection is also called gc.

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.