Signup/Sign In

Difference between Internal and External Fragmentation

In this tutorial, we will be covering the difference between Internal and External Fragmentation in Operating System.

Let us first understand what is fragmentation and the causes of fragmentation.

Fragmentation in OS

In the storage system of the computer, as processes are loaded space is allocated to them and this space is divided on the basis of fixed partitioning (where the size of partitions is fixed before any process gets loaded into the memory) and dynamic partitioning(where the size of partitions is decided at the run time and it is mainly according to the size of the process).

Likewise, processes are loaded and then removed from the memory due to which the free space in the memory gets broken down into smaller pieces. This mainly creates small non utilized fragmented memory spaces that are so small due to which normal processes can not fit into them.

The problem due to which memory space is not getting utilized at all is commonly known as Fragmentation in the operating system.

Fragmentation is further divided into two types:

Internal Fragmentation in OS

Internal Fragmentation is a problem that occurs when the process is allocated to a memory block whose size is more than the size of that process and due to which some part of the memory is left unused. Thus the space wasted inside the allocated memory block is due to the restriction on the allowed sizes of allocated blocks.

The above figure shows the Internal Fragmentation in Operating System

In the above diagram, the difference between memory allocated and required space or memory by the process is called internal fragmentation.

External Fragmentation in OS

When the memory space in the system can easily satisfy the requirement of the processes, but this available memory space is non-contiguous, So it can’t be utilized further. Then this problem is referred to as External Fragmentation.

The above Figure shows the External Fragmentation in Operating System

Suppose, we want to allocate memory to a process of size 8 MB and as In the above diagram, we can see that, there is enough space that is 9 MB to run a process of size 8MB but the memory that is fragments are not contiguous.

There is a solution for the problem of External Fragmentation and it is Compaction. The main goal is to shuffle the memory contents so as to place all the free memory together in one large block.

Also, Compaction is not always possible. Suppose if relocation is static and is done at the load time then in that case compaction cannot be done. Because compaction is only possible if the relocation is dynamic and is done at the execution time.

Difference Between Internal and External Fragmentation

Now let us cover the major difference between Internal Fragmentation and External Fragmentation.

Internal Fragmentation External Fragmentation
Internal Fragmentation occurs when the memory blocks of fixed-size are allocated to the processes. External Fragmentation occurs when the memory blocks of variable-size are allocated to the processes dynamically.
This type of fragmentation mainly occurs when the fixed size partition is assigned to a process whose size is less than the size of the partition due to which the rest of the space in the partition becomes unusable. When the memory space in the system can easily satisfy the requirement of the processes, but this available memory space is non-contiguous, So it can’t be utilized further.
The difference between allocated memory and memory required by a process is called Internal fragmentation. Unused memory spaces between the non-contiguous memory fragments that are too small to serve a new process are called External fragmentation.
It mainly refers to the unused space in the partition that resides in the allocated region; as suggested by the name. It mainly refers to the unused blocks of the memory that are not contiguous and hence are unable to satisfy the requirements of the process.
Best-fit block can be used to overcome the problem of Internal fragmentation. Compaction, segmentation, and paging can be used to overcome the problem of External fragmentation.
Paging suffers from Internal fragmentation. First-fit and best-fit suffer from external fragmentation.



About the author:
Aspiring Software developer working as a content writer. I like computer related subjects like Computer Networks, Operating system, CAO, Database, and I am also learning Python.