Difference Between Internal Fragmentation and External Fragmentation

Main Difference

The main difference between Internal Fragmentation and External Fragmentation is that Internal Fragmentation is the storage space that remains unused between the allocated memory blocks, whereas External Fragmentation is the holes between the contiguous blocks that are very small to serve a request.

Internal Fragmentation vs. External Fragmentation

Internal fragmentation is a type of fragmentation that takes place when larger memory assigned to a program rather than the required one. Here the free space is known as internal fragmentation. On the other side, external fragmentation is the type of free space that is formed between non-contagious blocks of memory.

The reason for the internal fragmentation is the partition of the memory into the blocks of fixed size. On the flip side, external fragmentation is the process that takes place when memory is divided into the blocks of variable size according to the size of different processes.

The problem of internal fragmentation can be solved by assigning memory to the programs in dynamic portions of memory blocks at their wish and free it when there is no need for it during the execution of a program. On the other side, external fragmentation can be resolved by paging, compaction, and segmentation so that memory can be assigned to a program in a non-contiguous manner.

Comparison Chart

Internal FragmentationExternal Fragmentation
The difference between the required memory for a program and the memory assigned for it is known as internal fragmentation.The holes or unused space that arises among non-contagious storage scraps or fragments and is too short to store a new program is known as external fragmentation.
Refers To
It refers to the space that remains unused between the blocks in an allocated region.It refers to the space that remains unused because it is too short to store a request.
Reason
The reason for internal fragmentation is the partition of the memory into the blocks of fixed size.External fragmentation takes place when memory or storage is composed of blocks of various sizes according to the size of different programs.
Occurrence
It occurs when more space is assigned to a program than the required one.It occurs when a program is removed from a memory leaving behind free space that causes external fragmentation.
Solution
It can be solved by assigning memory to the programs in dynamic portions of memory blocks at their wish and free it when there is no need for it during the execution of a program.It can be resolved by paging, compaction, and segmentation thus memory can be assigned to a program in a non-contiguous manner.

What is Internal Fragmentation?

Internal fragmentation is a type of fragmentation that takes place when larger memory assigned to a program rather than the required one. It takes place when the memory is allocated into the blocks of fixed size.

Whenever a program demands the memory, the system allocates a fixed-sized block. So, if the memory allocated to the program is larger than the requested memory, then the difference between the required memory for a program and the memory assigned for it is known as internal fragmentation. This space inside the block of fixed-sized cannot be assigned to any program because it would not be enough to store a new program.

The issue of internal fragmentation can be resolved by dividing the memory into the blocks of variable size and allocate the block of the best size to a program which is demanding for the memory. It will not resolve the problem of internal fragmentation totally, however, it will lessen it to a certain extent.

Example

Here is an example of internal fragmentation. The memory space is divided into the blocks of the fixed size of 18,470 bytes. But, a program demand for 18,460 bytes. The system will allocate it with a partitioned block of fixed size, i.e., of 18,470 bytes. As a result, 10 bytes of 18,470 bytes will remain empty that is the source of the internal fragmentation.

What is External Fragmentation?

External fragmentation is the holes or unused space that arises among non-contagious memory or storage fragments and is too short to store a new program. It takes place when there is an adequate amount of free space in the storage memory of a system to fulfill the memory demand of a program. But the demand for the program cannot be implemented or fulfilled as the available memory of the system is in a non-adjacent manner or mode.

Either you are applying first-fit memory allocation strategy or the best-fit memory allocation strategy, it will be the reason of external fragmentation. It occurs when a program is loaded and removed from a memory leaving behind free space that creates holes. There is a large number of such holes in the memory space that causes external fragmentation.

The first fit and best fit memory allocation strategy may reduce the amount of external fragmentation, but it cannot be totally removed. Paging, compaction, and segmentation may resolve external fragmentation.

The compaction algorithm causes the movement of all contents of memory to a side and frees a large block of memory. But it is a costly procedure. An alternative solution to solve this issue is to allow a process to attain physical memory in a non-contiguous way. This solution can be achieved by using the processes of paging and segmentation.

Example

In a computer system, when a program requests space, the blocks are assigned in the form of chunks. Suppose that for storing information and data in a system, there is a single chunk of memory vacant. Now, there is a program that we want to store in memory. The program will be saved dynamically in the memory, i.e., randomly, wherever it feels comfortable or discovers space. When the next program needs to be saved, it will adjust itself accordingly in the memory space. Now, we remove a program from the system. It will leave space or a hole in the memory. This hole or space cannot be used with the other storage even if it is present next to the free memory and causes the formation of external fragmentation.

Key Differences

  • The difference between the required memory for a program and the memory assigned for it is known as internal fragmentation whereas, the holes or unused space that arises between non-contagious memory fragments and is too short to store a new program is known as external fragmentation.
  • Internal fragmentation refers to the space that remains unused between the blocks in an allocated region, on the other hand, external fragmentation refers to the space that remains unused because it is too short to store a request.
  • The reason for internal fragmentation is the partition of the memory into the blocks of fixed size. Conversely, external fragmentation takes place when memory or storage is composed or divided into the blocks of variable size according to the size of different programs.
  • Internal Fragmentation occurs when more space is assigned to a program than the required one. On the flip side, external fragmentation occurs when a program is removed from a memory leaving behind free space in the system storage that causes external fragmentation.
  • The problem of internal fragmentation can be solved by assigning memory to the programs in dynamic portions of memory blocks at their wish and free it when there is no need for it during the execution of a program. On the other side, external fragmentation can be resolved by paging, compaction, and segmentation so that memory can be assigned to a program in a non-contiguous manner.
  • Conclusion

    The above discussion summarizes that Internal fragmentation and external fragmentation are two processes in computer storage that causes the wastage of storage space. Internal fragmentation occurs when more space is assigned to a program than the required one, whereas, external fragmentation occurs when a program is removed from the memory leaving behind free space.

    ncG1vNJzZmivp6x7pbXFn5yrnZ6Ysm%2FDyKSgaKGeqbKzusClZJ%2BqkZy6prrTmquip55iw7R5xLGrnqqelrlustGanqadnqmutbXOp2Y%3D