Lecture 18 - Memory Management Strategies

Memory is where all our stuff is. We really need it and need to use it efficiently. Let's look at some memory management strategies.

Memory Management Strategies

  1. Monoprogramming: only allow one program in memory. It's simple, and honestly a lot of cheap options would use this.
  2. Multi-programming/Fixed Partitions: we take our machine, divide it into chunks (of varying size) and load a program into each chunk.
Drawing canvas

Let's say we did this an had some programs use this memory:

Drawing canvas

What happens if a new program wants new memory? What happens if programs use memory outside of their space? What if a program wants more memory? This process doesn't really address this.

Each assembly/C program has assembly that creates memory addresses. But how can our program have memory addresses that work for itself, but don't break each other?

We could:

  1. Relative Addressing: All of a programs addresses are relative to the base address give to the program.
    • It'd be hard to have a Linked List to hold all the relative addresses, and then on a new program run have to calculate the relative addresses for every address.
  2. Base Register: For every memory reference, add a base register for that programs base offset.
Drawing canvas

But we also have the different text, data segments (and others that we would want to tag). Further, what if we need more space? Memory is usually requested dynamically so we want to address this.

Dynamic Partition

Here we want to carve out space per process.

Drawing canvas

The problem, similar with malloc, experiences fragmentation. What can we do about it?

We can, similar to malloc, try to keep track of allocated memory via:

Allocation Strategies

We could do:

This brings us to the discussion of...

Virtual Memory

Drawing canvas

The idea is that, just like the guy moving through the house as the rooms get destroyed, we can cache enough rooms in advance such that if we expect a far enough memory address, then we have it ready.