Segmentation vs Paging Trade-offs
What you'll learn: You'll understand the key advantages and disadvantages of segmentation versus paging as memory management strategies.
The Central Question
Both segmentation and paging solve the problem of managing process memory, but they take fundamentally different approaches. Segmentation divides memory into logical units (code, stack, heap), while paging uses fixed-size physical blocks. Each choice involves trade-offs.
Segmentation's Strengths
Segmentation mirrors how programs are actually structured. Each segment represents a meaningful unit—your code lives in one segment, your stack in another. This makes:
- Protection natural: Mark the code segment read-only, the stack no-execute
- Sharing easier: Multiple processes can share the same code segment
- Growth simpler: Segments can grow independently (stack grows down, heap grows up)
Segmentation's Weakness
The variable-sized segments cause external fragmentation. After loading and unloading many segments, memory becomes a Swiss cheese of gaps—you might have 10 MB free but can't allocate a 5 MB segment because no single hole is large enough.
Paging's Strengths
Fixed-size pages eliminate external fragmentation entirely. Any free frame can hold any page, making allocation trivial. The hardware support is also simpler and faster.
Paging's Weaknesses
Paging suffers from internal fragmentation (wasted space within the last page of each region) and loses the logical structure—pages don't respect code/data boundaries, making protection and sharing more complex.
The Practical Reality
Modern systems often use segmented paging: combine both approaches to get logical division benefits while keeping allocation simple. Each segment is internally divided into fixed-size pages.
Key Takeaway: Segmentation provides logical organization and natural protection but suffers external fragmentation; paging offers simple allocation and no external fragmentation but loses semantic meaning and causes internal fragmentation.