Build malloc, then a garbage collector

The two work areas a running program keeps: a stack that empties itself when a call returns, and a heap where things stay until someone says they are done. This lesson builds the part that hands out the heap and takes it back.
Before you start. A running program keeps two work areas in memory. The stack holds calls that have not finished, and empties itself as they return. The heap holds anything that must outlive the call that made it, and keeps it until the program gives it back. Forgetting to give it back is a leak. Using it after giving it back is a use-after-free (How Code Becomes Execution (compilers, stack & heap)). The kernel, the one program in charge of the hardware, hands out memory only in whole pages of several kilobytes, so something inside the program must cut pages into the small pieces it asks for (The address book every process carries). The first part of this build wrote a computer as a loop in Go (Build a stack machine); this part needs Go too, and nothing else from that one.