Contiguous Memory Allocation

This article gives a brief idea on what is contiguous memory allocation. Its disadvantages and the solution to them are also discussed.

Contiguous memory allocation


Contiguous memory allocation is one of the efficient ways of allocating main memory to the processes. The memory is divided into two partitions. One for the Operating System and another for the user processes. Operating System is placed in low or high memory depending on the interrupt vector placed. In contiguous memory allocation each process is contained in a single contiguous section of memory.

Memory protection

Memory protection is required to protect Operating System from the user processes and user processes from one another. A relocation register contains the value of the smallest physical address for example say 100040. The limit register contains the range of logical address for example say 74600. Each logical address must be less than limit register. If a logical address is greater than the limit register, then there is an addressing error and it is trapped. The limit register hence offers memory protection.

The MMU, that is, Memory Management Unit maps the logical address dynamically, that is at run time, by adding the logical address to the value in relocation register. This added value is the physical memory address which is sent to the memory.

The CPU scheduler selects a process for execution and a dispatcher loads the limit and relocation registers with correct values. The advantage of relocation register is that it provides an efficient way to allow the Operating System size to change dynamically.

Memory allocation

There are two methods namely, multiple partition method and a general fixed partition method. In multiple partition method, the memory is divided into several fixed size partitions. One process occupies each partition. This scheme is rarely used nowadays. Degree of multiprogramming depends on the number of partitions. Degree of multiprogramming is the number of programs that are in the main memory. The CPU is never left idle in multiprogramming. This was used by IBM OS/360 called MFT. MFT stands for Multiprogramming with a Fixed number of Tasks.

Generalization of fixed partition scheme is used in MVT. MVT stands for Multiprogramming with a Variable number of Tasks. The Operating System keeps track of which parts of memory are available and which is occupied. This is done with the help of a table that is maintained by the Operating System. Initially the whole of the available memory is treated as one large block of memory called a hole. The programs that enter a system are maintained in an input queue. From the hole, blocks of main memory are allocated to the programs in the input queue. If the hole is large, then it is split into two, and one half is allocated to the arriving process and the other half is returned. As and when memory is allocated, a set of holes in scattered. If holes are adjacent, they can be merged.

Now there comes a general dynamic storage allocation problem. The following are the solutions to the dynamic storage allocation problem.

  • First fit: The first hole that is large enough is allocated. Searching for the holes starts from the beginning of the set of holes or from where the previous first fit search ended.

  • Best fit: The smallest hole that is big enough to accommodate the incoming process is allocated. If the available holes are ordered, then the searching can be reduced.

  • Worst fit: The largest of the available holes is allocated.

First and Best fits decrease time and storage utilization. First fit is generally faster.


The disadvantage of contiguous memory allocation is fragmentation. There are two types of fragmentation, namely, Internal fragmentation and External fragmentation.

Internal fragmentation

When memory is free internally, that is inside a process but it cannot be used, we call that fragment as internal fragment. For example say a hole of size 18464 bytes is available. Let the size of the process be 18462. If the hole is allocated to this process, then two bytes are left which is not used. These two bytes which cannot be used forms the internal fragmentation. The worst part of it is that the overhead to maintain these two bytes is more than two bytes.

External fragmentation

All the three dynamic storage allocation methods discussed above suffer external fragmentation. When the total memory space that is got by adding the scattered holes is sufficient to satisfy a request but it is not available contiguously, then this type of fragmentation is called external fragmentation.

The solution to this kind of external fragmentation is compaction. Compaction is a method by which all free memory that are scattered are placed together in one large memory block. It is to be noted that compaction cannot be done if relocation is done at compile time or assembly time. It is possible only if dynamic relocation is done, that is relocation at execution time.

One more solution to external fragmentation is to have the logical address space and physical address space to be non contiguous. Paging and Segmentation are popular non contiguous allocation methods.

Related Articles

How to improve memorizing skills

In this article I am going to discuss about simple steps that can help anyone to improve his memorizing abilities. These days people complain about their weak memory power and tell that they cannot keep facts for a long time in their minds. Therefore some simple steps can help anyone to improve their skills in memorizing and in this way they can get rid of their weak memory problems.

Methods to improve Memory / Brain Power

A good memory is a very good tool for a student as well as any one in any profession. In this article I have written about how to improve your memory power. Children usually studies every thing but unable to produce it in the Answer sheet because of poor memory power. Here we will learn some simple steps to increase your memory power.

How can memory be improved?

Every body wants to improve their memory. Memory shows the power of man, so below I have mentioned some basics skills to improve your memory, which will affect your regular life as well as professional life.

How To Boost Up Memory Power The Ayurveda Ways

Don’t worry from your weakening memory loss. Some old Ayurvedic treatments help augment your memory power! By treating yourself with these, you can build your memory power angular. This article has the full details of how you can regain your memory loss the Ayurveda ways.

How to memorize things and objects quickly?

In this article, I will discuss how one can memorize things easily and efficiently. By following a few simple techniques, one can increase his capacity to learn and remember.

More articles: Memory


Guest Author: S.ABIRAMI16 Oct 2016

To overcome external fragmentation, one can do compaction.

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: