Implement a simple version of a generational garbage collector that uses only two regions (Appel 1989). The heap is divided into two even parts. The upper part holds cells that have been copied from the lower part as cells reachable from the root pointers. The lower part is used for memory allocation and holds only newer cells (see Figure 1a). After this part becomes full, the garbage collector cleans it by copying all reachable cells to the upper part (Figure 1b), after which allocations are made starting from the beginning of the lower part. After several turns, the upper part becomes full, too, and the cells being copied from the lower part are in reality copied to the lower part (Figure 1c). In this case, the cleanup process of the upper part is begun by copying all reachable cells from the upper part to the lower part (Figure 1d), and then all reachable cells are copied to the beginning of the upper part (Figure 1e).
Figure 1 A heap with two regions for Appel’s generational garbage collection.

We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.