Difference Between Similar Terms and Objects

Difference Between Internal Fragmentation and External Fragmentation

In the context of a file system, fragmentation is an inefficient use of storage space to store contents of a single file in different locations on a disk rather than in a single contiguous sequence of bits in one place. Fragmentation is a natural phenomenon which occurs physically on a hard drive or sometimes on a memory module when the data is not written closely enough on the drive.

The data is sometimes written out of order, meaning the pieces of data are not placed next to each other on the drive because of the frequent use of files. These pieces of data are referred to as fragments. At some point, the operating system would need to access the file system to find where the different fragments are located on the drive.

For example, when you create a new document, let’s say a word file; the file seems to be in one place. You can open the file, edit it or delete it – whatever you want. All the activities seem to be happening physically on the drive, at least that’s what you think.

The hard drive may be saving chunks of files in one area of the device, but the rest of it exists literally somewhere else on the storage device. In simple terms, fragmentation refers to the wasted storage space in the file system allowing gap to be developed between the different portions of a file.

Fragmentation basically occurs in the dynamic memory allocation system because it reserved too much space for the file resulting in open areas around it.

 

What is Internal Fragmentation?

It somehow relates to fixed size partitioning. The system allocates memory to various programs and processes by dividing them into small blocks as required by the program. However, more memory is allocated sometimes than is needed by the process, which eventually results in excess memory going waste or left unused.

For example, memory can only be allocated to programs in blocks divisible by 4, 8, or 16. When a process requests 24 bytes, it usually gets a block of 32 bytes, the excess 8 bytes is left unused. Thus unused memory resides within a specific allocated location and it is so small that a new process cannot be allocated to it, resulting in waste. This waste is termed as internal fragmentation. Probably the only way to remove this type of fragmentation is by dynamic memory allocation.

Difference Between Internal Fragmentation and External Fragmentation

 

What is External Fragmentation?

The main memory forms holes between portions of allocated memory that are too small to hold any process. It’s the downside of storage allocation algorithms, when contiguous blocks of unused spaces cannot serve a new request because the spaces are too small for large memory application needs. In simple terms, the non-contiguous blocks create holes in the memory resulting in unused storage that are outside the allocated regions, meaning it cannot be used along with the main memory for larger memory tasks. They end up being isolated and cannot be totally eliminated from the memory space. This is called external fragmentation. It can be removed by compaction which shuffles contents of the memory to place all free memory together.

Difference Between Internal Fragmentation and External Fragmentation

 

Difference between Internal and External Fragmentation

  1. Basics 

Internal fragmentation:

Internal fragmentation refers to extra spaces that go waste when more memory is allocated to a process than needed. It usually occurs when fixed size memory blocks are allocated to the programs or processes.

External fragmentation:

External fragmentation, on the contrary, refers to the unused spaces that are formed between the contiguous blocks of memory which are not adjacent to each other.

  1. Occurrence

Internal fragmentation:

The free space that forms within the allocated memory block when the memory allocated to the process is larger than the memory requested by the process is referred to as internal fragmentation. The “internal” refers to the unused bytes that reside in the larger memory blocks.

External fragmentation:

When the main memory forms holes that are too small to satisfy any request, it’s called external fragmentation.

  1. Reason

Internal fragmentation:

The main reason why internal fragmentation occurs is when memory is partitioned into fixed-sized blocks .

External fragmentation:

External fragmentation is a phenomenon which occurs when memory is divided into variable-sized blocks based on the size of different processes.

  1. Solution

Internal fragmentation:

Internal fragmentation is a natural phenomenon which can be eliminated by dynamic memory allocation that is to dynamically allocate portions of memory blocks to processes at their request and free it when they are no longer needed during execution of a program.

External fragmentation:

External fragmentation, on the other hand, can be eliminated by compaction, paging and segmentation so that memory can be allocated to a process in a non-contiguous manner.

Internal vs. External Fragmentation: Comparison Chart

Internal Fragmentation VERSUS External Fragmentation

Summary of Internal and External Fragmentation

Both internal and external fragmentation are natural phenomena related to unused memory space or memory being wasted. Internal fragmentation suffers from inefficient memory allocation which occurs when the memory allocated to a process is more than what requested, leaving unused space in the memory block eventually causing internal fragmentation. After the process is removed from the physical memory, free space becomes distributed here and there and no adjacent blocks of memory can be found, causing external fragmentation. However, both the phenomena can be avoided. Internal fragmentation can be reduced by allocating memory to processes dynamically, whereas external fragmentation can be best avoided by compaction, paging, and segmentation.

Latest posts by Sagar Khillar (see all)

Sharing is caring!


Search DifferenceBetween.net :




Email This Post Email This Post : If you like this article or our site. Please spread the word. Share it with your friends/family.


Leave a Response

Please note: comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

References :


[0]Null, Linda and Julia Lobur. The Essentials of Computer Organization and Architecture. Burlington: Jones & Bartlett Learning, 2006. Print

[1]Dhamdhere, D.M. Operating Systems: A Concept-based Approach. New Delhi: Tata McGraw-Hill Education, 2006. Print

[2]Nutt, Gary. Operating Systems. London: Pearson Education, 2003. Print

[3]Image credit: https://commons.wikimedia.org/wiki/File:মেমরি_ফ্রাগমেন্টেশন.png#/media/File:মেমরি_ফ্রাগমেন্টেশন.png

[4]Image credit: https://upload.wikimedia.org/wikipedia/commons/thumb/4/4a/External_Fragmentation.svg/500px-External_Fragmentation.svg.png

Articles on DifferenceBetween.net are general information, and are not intended to substitute for professional advice. The information is "AS IS", "WITH ALL FAULTS". User assumes all risk of use, damage, or injury. You agree that we have no liability for any damages.


See more about : ,
Protected by Copyscape Plagiarism Finder