Difference between Internal and External fragmentation

Fragmentation is one of the core topics of operating systems.

Let us understand what it means and how it occurs.

Now consider the word fragmentation. What comes to our mind as soon as we hear it? We can probably think of the process of breaking it down into pieces! Or possibly can be into smaller segments.

So basically, the word “Fragmentation” is derived from the word “Fragments”  which means smaller pieces. In simple terms, when any large piece is divided into smaller pieces for any purpose is called the process of fragmentation. This term is not only used in biology but also computer world. Computer systems do face this problem of fragmentation. Let us see how it happens.

Fragmentation can occur in the main memory as in the storage space where the memory is not used as the whole one slot but is used in the smaller segments. Where most of the smaller parts of the memory remain unused. Sometimes we do this intentionally to gain more memory space and to use the memory efficiently. But sometimes it also happens that the sum of all the smaller chunks of memory is larger than the memory space required but the data is not adjusted in pieces of memory and this is when fragmentation occurs.

This reduces the performance of memory and makes it inefficient.

Similarly, when we talk about fragmentation in computer devices, it means that there are small holes in memory that are unused and create blocks. In dynamic memory allocation, the allocation and deallocation process causes memory fragmentation. That means all the memory blocks are very small to fit in the given block and their combination is larger than the size of data blocks saved in the memory.

Memory Fragmentation is divided into two types.

  • Internal Fragmentation
  • External Fragmentation

Let us see in detail what these types of fragmentation mean. Before that let us discuss the key difference between Internal and External Fragmentation.

Difference between Internal and External fragmentation in tabular form

Internal Fragmentation External Fragmentation
Internal Fragmentation occurs when memory blocks of fixed size are allocated to the process External Fragmentation occurs when memory blocks of variable size are allocated to the process
It also occurs when the system or procedure is greater than the process It also occurs when the system or procedure is withdrawn
In this type of fragmentation, paging is employed In this type of fragmentation, segmentation is employed
Internal Fragmentation can be termed as the difference between allocated memory and the memory required by the process External Fragmentation can be termed as the non-used memory voids that are too small to serve a process
First-fit and best-fit is not suffered from Internal Fragmentation First-fit and best-fit is suffered from External Fragmentation
The best-fit block is the solution for internal fragmentation Compaction, paging, segmentation is the solution for External Fragmentation

What is Internal Fragmentation?

We all in any way attempt to use memory efficiently. Hence the memory space is divided into fixed-size blocks called pages. In the process of paging, pages are used to easily access and move the data from secondary memory to the main or primary memory. Sometimes there is wastage of this memory leading to internal fragmentation. It happens when memory blocks of fixed size are allocated to the process.

Whenever CPU/processor receives the process for execution, the primary memory stores the data of the process like a heap, code, register, in fixed-sized blocks called pages. If the size of the block is comparatively larger than the memory block needed by the processor then the remaining space which is neither too large nor too small is termed as memory wastage. In this process the overheads increases, it is necessary to keep a track of the data whether it may be used or unused.

The issue of internal fragmentation can be solved by assigning the best-fit block to the memory so that there are no holes and less memory wastage. Still, this problem cannot be unrooted or eliminated, but it can be reduced to some extent.

Let us explore what external fragmentation means.

What is External Fragmentation?

External Fragmentation is pretty similar to internal fragmentation. Still, they differ to some extent. We will discuss it here.

Let us take an example to understand this concept. Let us consider your memory has only one chunk of memory available to store the data or information. Now, as per CPU scheduling, a process arrives and we need to store its data in the memory. The data will be stored in the memory randomly i.e wherever it finds a place and is comfortable it will reside. Gradually, when the next process will arrive it will also grab and hold a place inside the memory. But what if we remove that data from the memory which was residing previously? In such a case, the removed data will leave a hole in the memory even if it is residing beside the free memory.

This problem is called external fragmentation. There are ways to solve this problem, one of them is called coalescing where the free memory blocks are combined and one large block is made.

Another solution is called paging and segmentation.

We have seen the difference between internal fragmentation and external fragmentation also we have discussed each of them in detail.

Author
Shraddha Changune
SVKM’s Institute of Technology, Dhule

References

1. https://www.tutorialspoint.com/difference-between-internal-fragmentation-and-external-fragmentation
2. https://microcontrollerslab.com/difference-between-external-and-internal-fragmentation/

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

error: Content is protected !!

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need fund to operate the site, and almost all of it comes from our online advertising.

Please add electricalvoice.com to your ad blocking whitelist or disable your adblocking software.

×