What is fragmentation? Explain internal and external fragmentation.
Interview preparation resource from Gate Smashers.
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.
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.
