What are fragmentation and its types in the operating system?

Hello Friends, In this blog post(What is fragmentation) I am going to explain to you the problem of fragmentation and its classification in the operating system. A fragmentation problem is related to an unused memory block which is generally left in a case when a process block is either of higher memory or lower memory concerning the available memory block.

In other words, if the total available memory is divided into multiple partitions of fixed size or variable size either statically or dynamically, the unused memory space remains internal or external to the partitions(What is fragmentation).

When a process comes and requests memory, its request is not satisfied while the sum of memory unused is greater than the process’s request. This phenomenon or problem is known as fragmentation(What is fragmentation).

Fragmentation is classified into two categories based on static and dynamic allocation of memory. One is internal fragmentation where memory blocks remain of fixed size|What is fragmentation|

Another is external fragmentation where a memory block is allocated at run time as per the requirement of memory|What is fragmentation|

Types of fragmentation:

Internal Fragmentation:

The phenomenon, in which there is a wasted space internal to a partition because the block of data loaded is smaller than the partition, is referred to as internal fragmentation.

When the partition is static that is fixed-sized partitioning, memory is wasted in each partition due to an object of a smaller size than the partition itself being loaded.

For example, suppose there is a partition of 10232 bytes in memory and a request comes for 10230 bytes of memory. If this request is satisfied then 2 bytes of memory will be left unused. This is also shown in the below-given fig.

Fig: Internal Fragmentation

External Fragmentation:

The phenomenon in which there is a waste space external to the partition due to the fact the memory that is external to all the partitions becomes increasingly fragmented is referred to as external fragmentation.

Dynamic partitioning or multiprogramming with variable partitions eliminates internal fragmentation by making each partition only as large as necessary to satisfy a request for space for an object.

With dynamic partitioning, those partitions are of variable length and number. When a process is brought into the main memory, it is allocated exactly as much memory as it requires and no more. An example using 64Mbytes of main memory is shown in the below-given fig.

Fig: External Fragmentation- The effect of dynamic partitioning

Initially, the main memory is empty, except for the operating system as shown in fig(a). The first three processes are loaded in, starting where the operating system ends and occupying just enough space for each process as shown in Fig (b) (c) (d). This leaves a hole at the end of the memory. That is too small for a fourth process.

At some point, none of the processes in memory is ready. The operating system swaps out process 2 as shown in fig(e), which leaves sufficient room to load a new process. Now, it loads process 4 as in Fig (f).

Because process 4 is smaller than process 2, another small hole is created. Later a point is reached at which none of the processes in the main memory is ready, but process 2, in the ready-suspended state, is available.

Because there is not sufficient room in memory for process 2, the operating system swaps process 1 out and swaps in process 2, as shown in Fig (g). and (h) respectively. Thus it leads to a situation in which there are a lot of small holes in memory which is external fragmentation.

So it is clear that external fragmentation solves the problem of internal fragmentation but it still suffers from the problem of unused memory space at run time.

One technique for overcoming external fragmentation is memory compaction. From time to time, the operating system shifts the processes so that they are contiguous and so that all the free memory is together in one block.

For example, as shown in Fig (h), compaction will result in a block of free memory of a length of 16M, which can be easily used for another process.

You can also go through a few more amazing blog links below related to segmentation and operating systems:

Segmentation In OS In Hindi…
Fragmentation In Hindi…
Paging vs Segmentation In Hindi…
What is segmentation in the operating system with examples…
Fragmentation & Its types in the operating system…
Similarities And Differences between Paging and Segmentation…

In the case of any queries, you can write to us at a5theorys@gmail.com we will get back to you ASAP.

Hope! you would have enjoyed this post about What is fragmentation & What the types of fragmentation are.

Please feel free to give your important feedback in the comment section below|What is fragmentation|

Have a great time! Sayonara!


I am a blogger by passion, a software engineer by profession, a singer by consideration and rest of things that I do is for my destination.