Operating System Interview Questions · Question 26

What is fragmentation? Explain internal and external fragmentation.

Interview preparation resource from Gate Smashers.

Interview-ready answer

Internal fragmentation is unused space inside an allocated block, while external fragmentation is free space split into separate holes that cannot satisfy a larger contiguous request.

Understand it clearly

Fixed-size allocation rounds requests up to an available block or page size. The unused portion remains reserved for that allocation and creates internal fragmentation. Smaller size classes or block sizes can reduce it, although they may add management overhead.

Variable-size contiguous allocation can leave holes as objects are created and freed. The total free memory may be sufficient but not contiguous, producing external fragmentation. Coalescing adjacent holes, compaction, relocation or non-contiguous paging can address it.

Internal fragmentation wastes space inside an allocated unit and cannot be recovered without changing that allocation. External fragmentation leaves usable free space split across the system. Paging addresses external fragmentation by using fixed frames, but may still waste part of the last page.

Quick comparison
BasisInternal fragmentationExternal fragmentation
LocationInside allocated blocksBetween allocated blocks
CauseBlock larger than requestFree space split into holes
Common withFixed-size allocationVariable-size contiguous allocation
ReductionSmaller or better size classesCoalescing, compaction or paging