Whenever a process is loaded or removed from the physical memory block, it creates a small hole in memory space which is called fragment. Due to fragmentation, the system fails in allocating the contiguous memory space to a process even though it have the requested amount of memory but, in a non-contiguous manner. The fragmentation is further classified into two categories Internal and External Fragmentation.
Both the internal and external classification affects data accessing speed of the system. They have a basic difference between them i.e. Internal fragmentation occurs when fixed sized memory blocks are allocated to the process without concerning about the size of the process, and External fragmentation occurs when the processes are allocated memory dynamically.
Let us move further and discuss the differences, reasons, solutions behind internal and external fragmentation with the help of comparison chart shown below.
Content: Internal Vs External Fragmentation
Comparison Chart
Basis for Comparison | Internal Fragmentation | External Fragmentation |
---|---|---|
Basic | It occurs when fixed sized memory blocks are allocated to the processes. | It occurs when variable size memory space are allocated to the processes dynamically. |
Occurrence | When the memory assigned to the process is slightly larger than the memory requested by the process this creates free space in the allocated block causing internal fragmentation. | When the process is removed from the memory, it creates the free space in the memory causing external fragmentation. |
Solution | The memory must be partitioned into variable sized blocks and assign the best fit block to the process. | Compaction, paging and segmentation. |
Definition of Internal Fragmentation
Internal fragmentation occurs when the memory is divided into fixed sized blocks. Whenever a process request for the memory, the fixed sized block is allocated to the process. In case the memory assigned to the process is somewhat larger than the memory requested, then the difference between assigned and requested memory is the Internal fragmentation.
This leftover space inside the fixed sized block can not be allocated to any process as it would not be sufficient to satisfy the request of memory by the process. Let us understand Internal fragmentation with the help of an example. The memory space is partitioned into the fixed-sized blocks of 18,464 bytes. Let us say a process request for 18,460 bytes and partitioned fixed-sized block of 18,464 bytes is allocated to the process. The result is 4 bytes of 18,464 bytes remained empty which is the internal fragmentation.
The overhead of keeping track of the internals hole created due to internal fragmentation is substantially more than the number of internal holes. The problem of internal fragmentation can be solved by partitioning the memory into the variable sized block and assign the best-sized block to a process requesting for the memory. Still, it will not totally eliminate the problem of internal fragmentation but will reduce it to some extent.
Definition of External Fragmentation
External fragmentation occurs when there is a sufficient amount of space in the memory to satisfy the memory request of a process. But the process’s memory request can not be satisfied as the memory available is in a non-contiguous manner. Either you apply first-fit or best-fit memory allocation strategy it will cause external fragmentation.
When a process is loaded and removed from the memory the free space creates the hole in the memory space, and there are many such holes in the memory space, this is called External fragmentation. Although the first fit and best fit can affect the amount of external fragmentation, it can not be totally eliminated. Compaction may be the solution for external fragmentation.
Compaction algorithm shuffles all memory contents to one side and frees one large block of memory. But compaction algorithm is expensive. There is an alternative solution to solve external fragmentation issue which will allow a process to acquire physical memory in a non-contiguous manner. The techniques to achieve this solution are paging and segmentation.
Key Differences Between Internal and External fragmentation
- The basic reason behind the occurrences of internal and external fragmentation is that internal fragmentation occurs when memory is partitioned into fixed-sized blocks whereas external fragmentation occurs when memory is partitioned into variable size blocks.
- When the memory block allotted to the process comes out to be slightly larger than requested memory, then the free space left in the allotted memory block causes internal fragmentation. On the other hands, when the process is removed from the memory it creates free space causing a hole in the memory which is called external fragmentation.
- The problem of internal fragmentation can be solved by partitioning the memory into variable sized blocks and assign the best fit block to the requesting process. However, the solution for external fragmentation is compaction, but it is expensive to implement, so the processes must be allowed to acquire physical memory in a non-contiguous manner, to achieve this the technique of paging and segmentation is introduced.
Conclusion
The problem of internal fragmentation can be reduced, but it can not be totally eliminated. The paging and segmentation help in utilising the space freed due to external fragmentation by allowing a process to occupy the memory in a non-contiguous manner.
Fissionix says
Best difference ever seen..
Ultimate description..
Atanu Mondal says
Very clear and compact explanation. No more words to say.
pranav.pk says
Use full .thank you
Supriya pandey says
Really very useful….compact…
Vishnu says
Very good explanation
bothwell says
great and clear
Mayurii says
Clear all views
Ravi Kumar says
Great, it clears my concept.
Vaibhav Katare says
Ultimate explanation 👌👌
Amit says
That’s too good
Nasruddiin Abdulwahaab says
Thanks very much.
Diksha Sharma says
Easily understandable
Thanks
Aman says
thanks you so much for this