Compaction, Overflow and Underflow in Array


Garbage collection is the process of collecting all unused nodes and returning them to available space. This process is carried out in essentially two phases. The first phase is marking phase where all node which is in use is marked. And Second Phase is compaction where all free partitions are made contiguous and merged together which can be allocated according to the needs of the new process.

Compaction is a process of moving all free memory at the one end to form large memory chunk and non-available chunk at other ends. Now this large memory chunk or space can be utilized by new processes.

  • Compaction solves the fragmentation problem by moving the all utilized block at one end.
  • Basically, compaction reduces the external fragmentation. It shuffles the memory content to place all free memory together to form one larger block.
  • It basically combines all empty spaces together and processes.
  • This process requires too much CPU utilization.
  • Instead of a large number of small free spaces, It combines all of them and forms a big free space that allows new incoming jobs.
  • The system also maintains the relocation information. On each new allocation of the job in the memory system takes an image and also after the completion of the job system takes an image.


Overflow is a condition that arises When we want to insert new data into the array data structure but there is no available space in that data structure. It means that there are no any empty list to store a new data, this situation is called overflow.


Underflow is a condition that arises when we want to delete some data from an array data structure but there are no any data available in that data structure.
It means that given data structure is empty so if empty then there is no any element is available to delete, this situation is called underflow.