Memory Management – Notes
(Operating System)
1. Definition
Memory Management is the process of managing the computer’s primary memory (RAM).
It keeps track of:
- Which memory parts are in use or free.
- Allocates memory to processes.
- Frees the memory when it is no longer needed.
2. Functions of Memory Management
1. Allocation – Provide memory to processes when needed.
2. Deallocation – Free memory after use.
3. Protection – Prevents one process from accessing another's memory.
4. Relocation – Adjust memory addresses when process is moved in RAM.
5. Sharing – Allows processes to share memory safely.
6. Logical to Physical Address Mapping.
3. Types of Memory Allocation
A. Contiguous Memory Allocation
- Entire memory is given as one continuous block.
- Easy to implement but may cause fragmentation.
Types:
- Single Partition: OS + One user process.
- Multiple Partition: OS + Multiple processes.
- Fixed Partitioning – Divides memory into fixed-size blocks.
- Variable Partitioning – Partitions vary based on process size.
Problems:
- Internal Fragmentation – Unused space within allocated block.
- External Fragmentation – Free space scattered between used blocks.
B. Non-Contiguous Memory Allocation
- Memory is allocated in chunks, not continuously.
- Allows better utilization of memory.
Major Techniques:
1. Paging
2. Segmentation
3. Virtual Memory
4. Logical vs Physical Address
Logical Address | Physical Address
----------------|------------------
Generated by CPU | Actual address in RAM
Used by program | Used by memory unit
Needs to be translated | Directly used
Note: MMU (Memory Management Unit) handles this translation.
5. Fragmentation
Type | Description
-----|-------------
Internal | Wasted space inside allocated memory block
External | Wasted space between blocks due to scattering
6. Paging (Overview)
- Divides memory into fixed-size blocks:
- Pages – logical memory
- Frames – physical memory
- Uses a page table for mapping pages to frames.
Helps avoid external fragmentation.
7. Segmentation (Overview)
- Divides memory into variable-sized logical segments like:
- Code, Data, Stack, Heap, etc.
- Uses segment table for mapping.
Maintains logical structure of the program.
8. Virtual Memory (Advanced)
- Technique to run larger programs than physical RAM.
- Uses disk space as temporary memory.
Key concepts:
- Demand Paging
- Page Fault
- Page Replacement Algorithms (FIFO, LRU)
9. Comparison Table
Feature | Paging | Segmentation
--------|--------|-------------
Division | Equal-sized pages/frames | Logical segments
Size | Fixed | Variable
Fragmentation | Internal possible | External possible
Mapping structure | Page Table | Segment Table
Final Summary Points
- Memory Management = Allocate, manage, and protect RAM.
- Logical ≠ Physical address – OS handles translation.
- Fragmentation = memory waste problem.
- Paging = fixed-size division of memory.
- Segmentation = logical division of memory.
- Virtual Memory = memory extension using disk.