Difference Between Internal and External Fragmentation

The main difference between internal and external fragmentation is that, in internal fragmentation, the memory block assigned to a process is large so the remaining portions cannot be used for some other process. But, in external fragmentation, the total memory space is enough to reside a process. However, it is not contiguous, so that space is unused.

Fragmentation is the process that divides a free memory space into smaller sections.  It can occur due to difficulty in allocating memory blocks to a process as they are smaller in size than the required. This issue can cause memory wastage as the memory blocks remain unused.  There are two types of fragmentation called internal and external fragmentation.

Key Areas Covered

1. What is Fragmentation
       – Definition, Functionality
2. What is Internal Fragmentation
      – Definition, Functionality
3. What is External Fragmentation
     – Definition, Functionality
4. Difference Between Internal and External Fragmentation
     – Comparison of Key Differences

Key Terms

Internal Fragmentation, External Fragmentation, Fragmentation, Operating System

Difference Between Internal and External Fragmentation - Comparison Summary

What is Fragmentation

When a process is loaded and removed from memory, that free space is divided into small pieces. These memory blocks are small in size, and it is not possible to allocate them for the same process or some other process. Therefore, those memory blocks remain unused. This issue is called fragmentation.

For example, assume that there is a process (p1) in the main memory. It takes 4MB space. Then it is removed from main memory and stored into the secondary memory. That initial memory space which belonged to p1 is now a free space. That space is divided into smaller sections such as 2MB and 2MB. If the process p1 has to be allocated to the main memory, it cannot use that previous space as it is already divided. So, that memory space remains unused.

What is Internal Fragmentation

In internal fragmentation, the memory block assigned to a process is larger than the required. Therefore, some portions of the memory are left unused. That space cannot be used for some other process. Assume that there is a process p1 which is 3MB. There is 4MB allocated for that process in the main memory. It is not possible to use the remaining 1MB to some other process. This 1MB is wasted. This wastage is called internal fragmentation.

Main Difference - Internal vs External Fragmentation

Figure 1: Internal Fragmentation

What is External Fragmentation

If the total memory space is enough to reside a process, but it is not continuous, then it is still not possible to use that space for a process. This type of fragmentation is called external fragmentation. Assume that the process is 4MB. There are 2MB, 1MB and 1MB spaces in the memory. The total memory is enough to reside the process. But those spaces are not contiguous as they are in various locations. Therefore, the space remains unused. This is external fragmentation.

Compaction or shuffle memory is a solution to external fragmentation. It will place all the free memory together into one large block.

Difference Between Internal and External Fragmentation

Figure 2: Compaction

According to the above diagram, there is a free space after p1 and p2. There is a space after p3, p4 and p5. Therefore, all processes are compacted to one side. Now there is a continuous free space. It is possible to allocate that free space to some other process. All free spaces are available in one location.

Difference Between Internal and External Fragmentation

Definition

Internal Fragmentation is a form of fragmentation that arises when there are sections of memory remaining because of allocating large blocks of memory for a process than required. External Fragmentation is a form of fragmentation that arises when there is enough memory available to allocate for the process but that available memory is not contiguous.

Functionality

In internal fragmentation, the memory block assigned to a process is large. Therefore, the remaining portion is left unused as it cannot be assigned to another process. In external fragmentation, memory space is enough to reside a process, but it is not contiguous. Therefore, that space cannot be used for allocation.

Solution

The solution for internal fragmentation is to assign partitions which are large enough for the processes. Compaction or shuffle memory content is the solution to overcome external fragmentation.

Conclusion

In internal fragmentation, the memory block assigned to a process is large so the remaining portions cannot be used for some other process. In external fragmentation, total memory space is enough to reside a process, but it is not contiguous, so that space unused. This is the main difference between Internal and External Fragmentation.

Reference:

1. “Operating System Memory Management.” Www.tutorialspoint.com, Tutorials Point, 8 Jan. 2018, Available here.

About the Author: Lithmee

Lithmee holds a Bachelor of Science degree in Computer Systems Engineering and is reading for her Master’s degree in Computer Science. She is passionate about sharing her knowldge in the areas of programming, data science, and computer systems.

Leave a Reply