Untitled Document
Untitled Document
Memory management is one of the most essential functions of an operating system. It deals
with the management of the computer’s physical memory (RAM). When multiple programs run
on a system, they all need memory to work, and the operating system ensures that each one
gets the required memory without interfering with others.
Why is it important?
● Allocates memory to processes when they need it and frees it when not in use.
Real-life example:
Imagine your memory as a desk. If you’re working on three different subjects (math, physics,
and programming), you need to place their books on the desk. Memory management is like
arranging these books properly so they don’t mix up and each has space.
Types of Memory
RAM (Random Access Memory): Temporary and volatile memory. It holds the data and
programs currently in use.
ROM (Read Only Memory): Permanent memory used to store the system’s firmware.
Hard drives and SSDs are non-volatile storage, used for storing data permanently.
High-speed memory placed between CPU and RAM. It stores frequently used data to
speed up access.
A portion of the hard drive used as if it were RAM. It allows more programs to run than
physical memory can support.
Example:
If your computer has 4GB RAM and you run many programs, it uses part of your hard drive as
temporary RAM. That’s virtual memory.
Memory must be allocated to processes efficiently. There are two main types:
● Fixed Partitioning: Memory is divided into fixed sizes. Small programs waste memory
(internal fragmentation).
● Variable Partitioning: Allocates memory as per process size, which may cause memory
holes (external fragmentation).
Non-Contiguous Memory Allocation:
● Paging: Memory is divided into equal-sized blocks (pages). These pages can be loaded
anywhere in RAM.
● Segmentation: Divides programs into segments (like code, stack, data). More logical for
programmer use.
● Show RAM divided into pages and segments with process parts spread across.
Paging is the most commonly used memory management technique in modern systems.
How it works:
● The CPU generates a logical address which is converted to a physical address using the
page table.
Advantages:
Disadvantages:
Virtual Memory
Virtual memory gives the illusion of a very large memory even if physical RAM is limited.
How it works:
● Stores parts of the process on the hard disk when RAM is full.
● If a needed page isn’t in memory, it causes a page fault. The OS then loads that page
from disk.
Thrashing:
When the system spends more time swapping pages in and out of memory than executing the
actual process.
Example:
Running heavy applications like Photoshop, Chrome, and MS Word together on a 4GB RAM
system—OS uses hard disk as extra memory.
Windows:
Linux:
● Uses virtual memory with a swap partition.
● Commands like top, free, and vmstat show real-time memory stats.
Comparison Table:
Conclusion:
Memory management is crucial for efficient functioning of an operating system. It allows multiple
processes to run simultaneously without conflicts. With concepts like paging and virtual memory,
systems can run more applications than the physical memory alone would allow. Understanding
how different OSes handle memory helps in optimizing applications and troubleshooting
performance issues.
References:
● GeeksforGeeks – https://www.geeksforgeeks.org/
● TutorialsPoint – https://www.tutorialspoint.com/