Contiguous memory allocation is a way to allocate adjacent parts of memory to a process or file that needs it. Since all of the available partitions of the memory space are in the same place, the unused sections are not distributed randomly.

Think of contiguous memory allocation as a means of forming a group where you don’t get to choose who you will work with. Instead of having the option to work with office mates from different floors in your office, for example, you end up with the people you’re on the same floor with.

Other interesting terms…

Read More about “Contiguous Memory Allocation”

How Does Contiguous Memory Allocation Differ from Non-Contiguous Memory Allocation?

A computer that uses contiguous memory allocation’s memory blocks will look something like this during the process:

As you can see, the memory space allotted for the process is not scattered. Instead, adjacent blocks were used for it.

Watch this video to learn more about contiguous memory allocation:

Non-contiguous memory allocation is the opposite of contiguous memory allocation. In it, a system allocates memory space in different locations to a process, depending on its requirements. In diagram terms, it looks like this:

The table below shows a more detailed comparison of the two types of memory allocation.

Contiguous Memory Allocation

How Does Contiguous Memory Allocation Work?

First off, you need to understand that a computer’s memory should accommodate the OS and user processes. Contiguous memory allocation usually divides the existing memory into two—one for the OS and another for all user processes or other applications. It does not divide OS or user processes by software but instead just puts them into adjacent blocks assigned to each big process category.

The usual way to implement contiguous memory allocation is to divide the memory into several fixed-sized portions. Each portion can be allocated to one process. The computer’s capability to run multiple programs thus depends on the number of partitions. Only when one section is free can another process from the input queue be loaded for execution. This method was initially used by the IBM OS/360 OS but is no longer used.

Strategies Used for Contiguous Memory Allocation Input Queues

Three strategies are commonly applied to allocate processes in contiguous memory allocation—first-, best-, and worst-fit. Take a look at how each technique works below.

  • First-fit strategy: The system allocates the first available memory block big enough for the process. Searching can start either from the first block or where the previous first-fit search ended. It stops looking as soon as it finds a free block that fits the process.
  • Best-fit strategy: The system allocates the smallest memory block available that fits the process. It searches the entire list of blocks unless they are arranged according to size. The strategy leaves the smallest block unused.
  • Worst-fit strategy: The system allocates the largest available memory block. It must search the entire list unless the blocks are sorted by size. The procedure leaves the largest memory block unused.

Simulations showed that first- and best-fit are better than worst-fit in terms of decreasing time and storage utilization. Neither first- nor best-fit is, however, clearly better than the other in terms of storage utilization but first-fit is generally faster.

Now, you have an idea on how to answer the question “What is contiguous memory allocation?” You also learned how it differs from its opposite—non-contiguous memory allocation, how it works, and what strategies are used to implement it.