Contiguous Memory Allocation in OS
Contiguous Memory Allocation is a type of memory allocation technique where processes are allotted a continuous block of space in memory. This block can be of fixed size for all the processes in a fixed-size partition scheme or can be of variable size depending on the requirements of the process in a variable-size partition scheme.
What is Contiguous Memory Allocation in OS?
Contiguous memory allocation in the operating system is a memory allocation technique. But what is memory allocation? When a program or process is to be executed, it needs some space in the memory. For this reason, some part of the memory has to be allotted to a process according to its requirements. This process is called memory allocation.
One such memory allocation technique is contiguous memory allocation. As the name implies, we allocate contiguous blocks of memory to each process using this technique. So, whenever a process wants to enter the main memory, we allocate a continuous segment from the totally empty space to the process based on its size.
Stop learning AI in fragments master a structured AI Engineering Course with hands-on GenAI systems with IIT Roorkee CEC Certification
Transform Your Career
Choose from our industry-leading programs designed for career success
Modern Software and AI Engineering Program
Master full-stack development with AI integration
+1000 moreModern Data Science and ML with specialisation in AI
Advanced data science techniques with AI specialization
+1000 moreAdvanced AIML with Specialisation in Agentic AI
Deep dive into AIML with focus on Agentic systems
+1000 moreDevOps, Cloud & AI Platform Engineering
Build and manage AI-powered cloud infrastructure
+1000 moreAI Engineering Advanced Certification by IIT-Roorkee
Premier AI engineering certification from IIT-Roorkee
Contiguous Memory Allocation Techniques
Whenever a process has to be allocated space in the memory, following the contiguous memory allocation technique, we have to allot the process a continuous empty block of space to reside. This allocation can be done in two ways:
-
Fixed-size Partition Scheme
-
Variable-size Partition Scheme
Let us look at both of these schemes in detail, along with their advantages and disadvantages.
Fixed-size Partition Scheme
In this type of contiguous memory allocation technique, each process is allotted a fixed-size continuous block in the main memory. This method is called fixed partitioning, where the complete memory is divided into continuous fixed-size partitions, and each partition holds exactly one process when a new process is loaded. Because irrespective of the size of the process, each is allotted a block of the same size memory space. This technique is also called static partitioning

In the diagram above, we have three processes in the input queue that have to be allotted space in the memory. As we are following the fixed-size partition technique, the memory has fixed-sized blocks. The first process, which is of size 3MB, is allotted a 5MB block, the second process, which is of size 1MB, is also allotted a 5MB block, and the 4MB process is also allotted a 5MB block as allocated memory blocks. So, the process size doesn’t matter because the partition size is fixed. Each is allotted the same fixed-size memory block.
It is clear that in this scheme, the number of continuous blocks into which the memory will be divided will be decided by the amount of space each block covers, and this, in turn, will dictate how many processes can stay in the main memory at once.
Note: The number of processes that can stay in the memory at once is called the degree of multiprogramming. Hence, the degree of multiprogramming of the system is decided by the number of blocks created in the memory.
Advantages
The advantages of a fixed-size partition scheme are:
-
Because all of the blocks are the same size, this scheme is simple to implement. All we have to do now is divide the memory into fixed blocks and assign processes to them.
-
It is easy to keep track of how many blocks of memory are left, which in turn decides how many more processes can be given space in the memory.
-
As at a time multiple processes can be kept in the memory, this scheme can be implemented in a system that needs multiprogramming.
Disadvantages
Though the fixed-size partition scheme has many advantages, it also has some disadvantages:
-
As the size of the blocks is fixed, we will not be able to allot space to a process that has a greater size than the block.
-
The size of the blocks decides the degree of multiprogramming, and only that many processes can remain in the memory at once as the number of blocks.
-
If a process is smaller than the block, the unused part of the allotted space is wasted, causing internal fragmentation even when enough total memory or total memory still exists.

Variable-size Partition Scheme
In this type of contiguous memory allocation technique, no fixed blocks or partitions are made in the memory. Instead, each process is allotted a variable-sized block depending upon its requirements. That means, whenever a new process wants some space in the memory, if available, the required amount is assigned from available memory and free memory as needed. Hence, the size of each block depends on the size and requirements of the process which occupies it.
In the diagram above, there are no fixed-size partitions. Instead, the first process needs 3MB memory space and hence is allotted that much only. Similarly, the other 3 processes are allotted only that much space that is required by them as allocated memory blocks of different sizes.
As the blocks are variable-sized, which is decided as processes arrive, this scheme is also called Dynamic Partitioning.
Advantages
The advantages of a variable-size partition scheme are:
-
As the processes have blocks of space allotted to them as per their requirements, there is no internal fragmentation. Hence, there is no memory wastage in this scheme.
-
The number of processes that can be in the memory at once will depend upon how many processes are in the memory and how much space they occupy. Hence, it will be different for different cases and will be dynamic.
-
As there are no blocks that are of fixed size, even a process of big size can be allotted space.
Disadvantages
Though the variable-size partition scheme has many advantages, it also has some disadvantages:
-
Because this approach is dynamic, a variable-size partition scheme is difficult to implement.
-
It is difficult to keep track of processes and the remaining space in the memory. Dynamic partitioning can suffer from external fragmentation, where free space is split into small gaps between blocks.
Even when there is enough total memory, a large new process may not fit unless the space is compacted into a large enough contiguous block.
Become the Ai engineer who can design, build, and iterate real AI products, not just demos with an IIT Roorkee CEC Certification
Turn Learning into Career Growth
Strategies Used for Contiguous Memory Allocation Input Queues
So far, we've seen the two types of schemes for contiguous memory allocation. But what happens when a new process comes in and has to be allotted a space in the main memory? How is it decided which block or segment it will get?
Processes that have been assigned continuous blocks of memory will fill the main memory at any given time. However, when a process completes, it leaves behind an empty block known as a hole. This space could also be used for a new process. Hence, the main memory consists of processes and holes, and any one of these holes can be allotted to a new incoming process. We have three strategies to allot a hole to an incoming process:
Scaler Placement Report and Statistics
Scaler learners achieved 2.5x salary growth with average post-Scaler CTC reaching ₹23L.
First-Fit
This is a very basic strategy in which we start from the beginning and allot the first hole, which is big enough as per the requirements of the process. The first-fit strategy can also be implemented in a way where we can start our search for the first-fit hole from the place we left off last time.
Best-Fit
This is a greedy strategy that aims to reduce any memory wasted because of internal fragmentation in the case of static partitioning, and hence we allot that hole to the process, which is the smallest hole that fits the requirements of the process. Hence, we need to first sort the holes according to their sizes and pick the best fit for the process without wasting memory.
Worst-Fit
This strategy is the opposite of the Best-Fit strategy. We sort the holes according to their sizes and choose the largest hole from the available memory to be allotted to the incoming process. The idea behind this allocation is that it leaves a large block of memory as free space for future allocations. Hence, this will create a hole that will be large enough to accommodate a few other processes.
-
In contiguous memory allocation, we allocate contiguous blocks of memory to each process when it is brought in the main memory to be executed.
-
There are two techniques for contiguous memory allocation:
-
Fixed Size Partitioning: Each process is allotted to a fixed size continuous block in the main memory.
-
Variable Size Partitioning: Each process is allotted space depending upon its requirements. There is no defined fixed-size block.
-
There are three strategies to allot a hole to an incoming process:
-
First-Fit: Allot the process to the first hole, which is big enough.
-
Best-Fit: Allot the smallest hole that satisfies the requirements of the process.
-
Worst-Fit: Allot the largest size hole among all to the incoming process.