LearnViz CompSci
Home / Learn / Operating Systems / Memory Management

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

  1. Programs request memory.
  2. The manager finds free space.
  3. It allocates a block and records it.
  4. Isolation prevents one program from touching another's block.
  5. 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

How to study this topic

  1. Read the explanation above and restate the definition in your own words.
  2. Open the interactive lesson and answer its mini quiz.
  3. Read the common pitfall, then write a short example that avoids it.
  4. Check your understanding in the Operating Systems quiz, and revisit the topic if you miss a question.

Frequently asked questions

What is Memory Management?
Allocating and tracking memory among programs. It belongs to Operating Systems and is an intermediate-level topic.
Where do people use Memory Management?
Every running program depends on it for heap and stack space, shared libraries and memory-mapped files.
What is the most common mistake with Memory Management?
Memory leaks, fragmentation, thrashing and out-of-memory conditions degrade or kill programs; Linux may invoke the OOM killer.
What should I learn before this topic?
Start with Dining Philosophers, the topic just before it in Operating Systems.
How can I practice it?
Answer the mini quiz in the interactive lesson, then take the Operating Systems quiz.
Is Memory Management hard to learn?
It is an Intermediate topic. Be comfortable with the Beginner topics in this area first, then read the common pitfall carefully, since it is where most mistakes happen.
How long does it take to learn Memory Management?
Most learners can read the explanation and finish the interactive lesson in under an hour. Fluency comes from applying the idea, so plan a few short practice sessions with the quiz.
Which topics are related to Memory Management?
Dining Philosophers, Paging, Deadlock Prevention and Avoidance are closely connected. The full list is in the related topics section of this page.
What should I study after Memory Management?
Continue with Paging, the next topic in Operating Systems.

Related topics