Fragmentation: Internal vs External
- Process Management
- Memory Management
- Deadlocks
- OS Introduction & Fundamentals
- CPU Scheduling Algorithms
- Threads & Concurrency
- Inter-Process Communication (IPC)
- Process Synchronization
- Virtual Memory & Paging
- File Systems
- Disk Scheduling
- I/O Management
Internal Fragmentation: Wasted Space Inside an Allocated Block
Fixed partition size: 100k
Process actually needs: 62k
+---------------------------+
| Process (62k) | Wasted (38k) |
+---------------------------+
(the wasted 38k is trapped inside this process's own partition,
unusable by any other process)Internal fragmentation happens when an allocated block is larger than what a process actually needs, wasting the difference - as covered in the previous note, this is the characteristic problem of fixed-size partitioning.
External Fragmentation: Wasted Space Scattered Between Blocks
+--------+------+--------+------+--------+------+
| Used | Free | Used | Free | Used | Free |
+--------+------+--------+------+--------+------+
20k 15k 30k 10k 25k 12k
Total free space: 37k - but no single free gap is large enough
for a new 30k process to fit into, even though 37k total is technically free.External fragmentation happens when total free memory is genuinely sufficient, but it's scattered into small, non-contiguous gaps rather than existing as one continuous block - even though enough total space exists, no single gap may be large enough to satisfy a new request.
Comparing the Two Kinds of Waste
| Internal Fragmentation | External Fragmentation | |
|---|---|---|
| Where the waste is | Inside an allocated block | Between allocated blocks, scattered |
| Associated with | Fixed-size partitioning | Dynamic-size partitioning |
| Common fix | Choosing an appropriately small partition size | Compaction, or paging (covered later in this section) |
Compaction: One Direct Fix for External Fragmentation
Compaction shifts all currently allocated blocks together, consolidating every scattered free gap into one single, large, contiguous free block - solving the immediate problem, but at the real cost of the time it takes to physically move data around in memory.
Why This Motivated an Entirely Different Approach: Paging
Rather than continuing to patch external fragmentation with periodic compaction, paging (covered in detail later in this section) sidesteps the problem in a fundamentally different way - by not requiring a process's memory to be contiguous at all.