On this page
  1. Memory Management Models
  2. Contents
  3. Comparing the Four Major Models
  4. Cycles, Pauses & Deterministic Cleanup

Memory Management Models

Prev: Pointers, References & Indirection | Up: memory_and_execution | Next: paradigms
Rel: Python Memory Management, Call Stack & Heap, C Dynamic Memory & Allocators, Rust Ownership, Borrowing & Lifetimes, JVM Garbage Collection (G1 & ZGC), C++ RAII & Smart Pointers
Ref: Wikipedia — Garbage Collection (Computer Science)
Tags: #public #prog #programming #memory #gc #ownership


Contents


Comparing the Four Major Models

Model Examples How Memory Is Reclaimed Key Trade-off
Manual C, Zig Programmer calls malloc/free (or arena allocators) Zero runtime overhead, full control; risk of leaks & use-after-free
Reference Counting CPython, Swift Each object counts incoming references; freed immediately at 0 Deterministic cleanup; cannot free cycles alone + atomic count cost
Tracing GC JVM, Go, V8 (JS) Periodically traces reachable graph from roots (mark-sweep / generational) Handles cycles & simplifies code; higher RAM + stop-the-world pauses
Ownership / RAII Rust, modern C++ Single owner per value; compiler inserts drop/destructor at scope exit Memory safety + zero GC pauses; stricter compile-time borrow rules

Cycles, Pauses & Deterministic Cleanup

Linked from

Related notes