1. Contiguous Memory Allocation :
Contiguous memory allocation is basically a method in which a single contiguous section/part of memory is allocated to a process or file needing it. Because of this all the available memory space resides at the same place together, which means that the freely/unused available memory partitions are not distributed in a random fashion here and there across the whole memory space.
The main memory is a combination of two main portions- one for the operating system and other for the user program. We can implement/achieve contiguous memory allocation by dividing the memory partitions into fixed size partitions.
2. Non-Contiguous Memory Allocation :
Non-Contiguous memory allocation is basically a method on the contrary to contiguous allocation method, allocates the memory space present in different locations to the process as per it’s requirements. As all the available memory space is in a distributed pattern so the freely available memory space is also scattered here and there.
This technique of memory allocation helps to reduce the wastage of memory, which eventually gives rise to Internal and external fragmentation.
Difference between Contiguous and Non-contiguous Memory Allocation :
|S.NO.||Contiguous Memory Allocation||Non-Contiguous Memory Allocation|
|1.||Contiguous memory allocation allocates consecutive blocks of memory to a file/process.||Non-Contiguous memory allocation allocates separate blocks of memory to a file/process.|
|2.||Faster in Execution.||Slower in Execution.|
|3.||It is easier for the OS to control.||It is difficult for the OS to control.|
|4.||Overhead is minimum as not much address translations are there while executing a process.||More Overheads are there as there are more address translations.|
|5.||Internal fragmentation occurs in Contiguous memory allocation method.||External fragmentation occurs in Non-Contiguous memory allocation method.|
|6.||It includes single partition allocation and multi-partition allocation.||It includes paging and segmentation.|
|7.||Wastage of memory is there.||No memory wastage is there.|
|8.||In contiguous memory allocation, swapped-in processes are arranged in the originally allocated space.||In non-contiguous memory allocation, swapped-in processes can be arranged in any place in the memory.|
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.