Intermediate Topic 26 of 51 Operating Systems
Memory Management
Allocating and tracking memory among programs.
How it works
The OS memory manager allocates physical memory to processes, tracks which parts are free or used, protects processes from one another and gives each an address space through virtual memory. Techniques include paging, segmentation, swapping, demand loading and copy-on-write. It balances utilization against fragmentation and speed, and reclaims memory when the system is under pressure.
Step-by-step walkthrough
- Programs request memory.
- The manager finds free space.
- It allocates a block and records it.
- Isolation prevents one program from touching another's block.
- When memory is freed it returns to the free pool.
Where it is used
Every running program depends on it for heap and stack space, shared libraries and memory-mapped files. Servers use it to pack many processes, and containers apply limits through cgroups.
Common pitfall
Memory leaks, fragmentation, thrashing and out-of-memory conditions degrade or kill programs; Linux may invoke the OOM killer. Overcommit assumes not all allocated memory is used. Measure resident versus virtual size when diagnosing problems, free what you allocate and avoid unnecessary copies.
Where it fits in the course
Memory Management is topic 26 of 51 in Operating Systems, rated Intermediate. It follows Dining Philosophers. The next topic is Paging.
Practice and explore
- Open the interactive lesson, with a mini quiz.
- Take the Operating Systems quiz.
How to study this topic
- Read the explanation above and restate the definition in your own words.
- Open the interactive lesson and answer its mini quiz.
- Read the common pitfall, then write a short example that avoids it.
- Check your understanding in the Operating Systems quiz, and revisit the topic if you miss a question.
Frequently asked questions
What is Memory Management?
Where do people use Memory Management?
What is the most common mistake with Memory Management?
What should I learn before this topic?
How can I practice it?
Is Memory Management hard to learn?
How long does it take to learn Memory Management?
Which topics are related to Memory Management?
What should I study after Memory Management?
Related topics
- Dining Philosophers (Operating Systems)
- Paging (Operating Systems)
- Deadlock Prevention and Avoidance (Operating Systems)
- Segmentation (Operating Systems)
- Manual Memory Management (Languages & Compilers)
- Memory Barriers (Concurrency & Parallelism)
- Dependency Management (DevOps & Tooling)