Lecture 16: Automatic Memory Management
1 Reference Counting
2 Mark & Sweep
3 Copying Collection
8.3

Lecture 16: Automatic Memory Management

Now that our language has heap-allocated values (lambdas and tuples), the execution of our program will rapidly produce a lot of heap allocations which will quickly become obsolete, but we currently have no way of freeing those objects on the heap: this will rapidly exhaust our heap space and our program will crash. One non-solution would be to introduce a manual deletion primitive, whereby programmers could explicitly free some heap-allocated value. This has several problems:

But most annoyingly, programmers didn’t have to do anything explicit in order to allocate memory, so it seems unfair to force them to manually deallocate memory. Instead, we need to

1 Reference Counting

2 Mark & Sweep

3 Copying Collection