What is memory compaction, and what problem does it solve in contiguous allocation?

Last updated 5 July 2026

  • Compaction moves allocated blocks together so scattered free holes merge into one large contiguous region.

  • It fixes external fragmentation: enough total free memory exists but no single hole fits a large request.

  • It requires execution-time address binding and is expensive (copying stalls execution). Paging avoids the need by dropping contiguity.

  • https://www.geeksforgeeks.org/operating-systems/compaction-in-operating-system/
  • https://csegyan.com/Operating-System/Fragmentation-in-OS.php
  • https://codecake.ai/blog/memory-allocation-in-os/
  • https://www.ituonline.com/tech-definitions/what-is-fragmentation-memory/
  • https://www.geeksforgeeks.org/operating-systems/difference-between-fragmentation-and-compaction/
  • https://docs.kernel.org/core-api/mm-api.html
All Operating Systems interview questions