Garbage collection automatically reclaims memory occupied by objects that are no longer reachable by a program. It reduces the risks of manual memory management, but can reduce execution speed, consume additional compute resources, and stall execution. It also manages memory only, not resources such as network sockets or database handles. section 1.2.2
Garbage collection appears as one option in a broader memory-management comparison:
- Manual memory management, used by C and C++, provides low-level control but increases the risk of memory-related correctness errors. section 1.2.2
- Garbage-collected languages include Java, C#, Python, Ruby, and Go, using automatic memory management to make programs safer. section 1.2.2
- Rust takes a different approach: its ownership model provides automatic memory management and memory safety without a garbage collector. section 1.2.2
- Rust makes ownership explicit, models resource management around RAII, and uses smart pointers for safe memory usage. section 1.2.2








