Before Compaction
Before compaction, the main memory has some free space between occupied space. This condition is known as external fragmentation. Due to less free space between occupied spaces, large processes cannot be loaded into them.
Main Memory |
---|
Occupied space |
Free space |
Occupied space |
Occupied space |
Free space |
Compaction in Operating System
Compaction is a technique to collect all the free memory present in the form of fragments into one large chunk of free memory, which can be used to run other processes.
It does that by moving all the processes towards one end of the memory and all the available free space towards the other end of the memory so that it becomes contiguous.
It is not always easy to do compaction. Compaction can be done only when the relocation is dynamic and done at execution time. Compaction can not be done when relocation is static and is performed at load time or assembly time.
For students preparing for competitive exams like GATE, understanding memory management techniques such as compaction is crucial. Our GATE course offers detailed coverage of these concepts, including practical examples and scenarios, to help you grasp the intricacies of dynamic and static relocation and their implications for memory management.
Contact Us