Fragmentation, External Fragmentation, Internal Fragmentation, first fit, best fit, worst fit in operating systems (OS)

Fragmentation, External Fragmentation, Internal Fragmentation in operating systems (OS)

In this tutorial, we will try to answer the following questions;

What is Fragmentation? What is External Fragmentation? What is Internal Fragmentation? Comparison of external fragmentation VS internal fragmentation?


The user of a computer continuously load and unload the processes from main memory. Processes are stored in blocks of the main memory. When it happens that there are some free memory blocks but still not enough to load the process, then this condition is called fragmentation.

Fragmentation is a condition that occurs when we dynamically allocate the RAM to the processes, then many free memory blocks are available but they are not enough to load the process on RAM.

 There are two types of fragmentation;

  1. External fragmentation
  2. Internal fragmentation

1. External fragmentation

Total free RAM space is enough to load a process but the process still can’t load because free blocks of RAM are not contiguous. In other words, we can say that all free blocks are not located together. For example, in the following diagram, we have a total 10 KB space free but it is not together located, so if a process with 10KB size wants to loads on the RAM, then can’t load due to external fragmentation. But in the diagram on the right side we can see that 10KB space is contiguously free, so here if a process of 10KB wants to load on the RAM then can execute.

external fragmentation
Figure: external fragmentation


Internal fragmentation occurs when fixed sized memory blocks are available and a process gets a block that is too much larger than the storage requirement of a process. The worst fit is mostly a big reason for internal fragmentation.

internal fragmentation memory management operating systems os
Figure: internal fragmentation memory management operating systems os

Comparison of external fragmentation VS internal fragmentation



Basics of fragmentation When different size memory blocks are dynamically allocated to the processes. When fixed sized memory blocks are allocated to the processes.
When  fragmentation


When the process releases the RAM, it creates the free space in the RAM which leads to cause external fragmentation. When the memory assigned to the process is greater as compared to the memory requested by the process.
The solution of fragmentation segmentation. paging and Compaction The memory must be partitioned into variable sized blocks. Further, assign the best-fit block to the process.

First-fit memory allocation
In first-fit memory allocation, OS Allocate the first hole to the process that is big enough and process size is less.

Best-fit memory allocation
In best-fit memory allocation, OS Allocate the most suitable smallest hole to the process. In best-fit memory, waste is less as compared to the worst fit and first, fit memory allocations.

Worst-fit memory allocation
In Worst-fit memory allocation, OS Allocate the largest hole to the process and results in wastage of a large amount of memory.

Fazal Rehman Shamil
Welcome to all friends. The reason for our success is only your love for T4Tutorials. Our team is always available to answer your queries regarding any kind of confusions or discussion regarding your study and career matters. For discussion with us please join our facebook group "". The link of the group is mentioned below. Thanks and love to all for connecting with us. We are nothing without you. Love you all.....

Leave a Reply