How do we manage the memory of multiple processes?

We have multiple processes in memory. Overtime, new processes will emerge, and we will run out of memory.

When this happens, we should evict some memory to free up space. Even better, we can do so preemptively, and evict a process from memory when it is idle.

The above is a simplification. We have to consider How do we allocate memory?