Manual Memory management in C

malloc() ⇒ allocates the memory free() ⇒ frees up the memory


Automatic memory management

  • Reference counting ↳ Can’t deal with Cycles ↳ Can lead to memory leaks

Garbage Collection

  1. Mark
  2. Reachability check
  3. Sweep unreachable memory


Source: Garbage Collection (Mark & Sweep) - Computerphile