Main Memory: Allocation, Linking & Segmentation

memory management

Imagine a single big whiteboard that a whole office full of people must share. Everyone needs space to scribble, nobody should erase anyone else's notes, and when someone leaves their space should be freed for the next person. Computer memory (RAM) is that whiteboard, the running programs are the people, and memory management is the part of the operating system that hands out space, keeps track of who has what, and makes sure no one writes over anyone else.

Concretely, the OS must do several jobs at once. It must keep track of which parts of physical memory are in use and which are free. It must decide where to place a program when it loads, and it must translate the addresses the program thinks in (its own private numbering) into the real hardware addresses in the chip. It must protect each program so a bug in one cannot corrupt another or the OS itself. And because there is rarely enough RAM for everything, it must decide what to keep in memory and what to push aside. This field covers the groundwork for all of that: addresses, binding, the hardware that translates, how memory is carved into pieces, and the tools that turn your source code into a runnable image.

Why it matters: memory is one of the two resources (CPU time being the other) that every process competes for, and it is the one where mistakes are most dangerous. Without memory management many processes could not safely share one machine at all. Note that this field is the classical, physical-memory groundwork; the cleverer trick of paging (cutting memory into fixed-size pieces) and the illusion of virtual memory larger than RAM are built on top of these ideas and are covered separately.

Three programs are running: a browser using 800 MB, a text editor using 50 MB, and a music player using 120 MB. The OS records exactly which physical bytes each one owns, refuses to let the editor read the browser's memory, and reclaims every byte the music player held the moment you close it.

Sharing one physical RAM safely among many processes is the whole job.

Memory management is not only about finding free space; protection (keeping each process inside its own region) is just as central, and it relies on hardware help — software alone cannot do it cheaply enough on every memory access.

Also called
main-memory management主記憶體管理