Know The Difference Between Internal And External Fragmentation
Table of content:
- Types of Fragmentation
- Internal Fragmentation
- External Fragmentation
- Difference between Internal and External Fragmentation
Fragmentation in an operating system refers to the phenomenon where available memory or storage becomes divided into small, non-contiguous segments. This can happen in physical memory (RAM) and secondary storage (hard drives, SSDs). Fragmentation can negatively impact system performance, efficiency, and overall resource utilization. It is actually an unwanted issue and leads to the following problems.
- The efficiency of the operating system is reduced.
- Memory space is inadequate for use.
- Storage capacity remains unused for many processes.
Types of Fragmentation
There are two types of fragmentation in an OS:
1. Internal Fragmentation
2. External Fragmentation
There is another type of fragmentation called data fragmentation, which combines the two forms of fragmentation together. Let us understand the two types of fragmentation in detail below.
Internal Fragmentation
Internal fragmentation allocates larger memory blocks for a process such that the extra unused spaces in the memory left after allocation are wasted.
In this type of fragmentation, when a process or method requests memory, the system allocates memory split in the form of mounted-sized blocks. This shows that the memory allocated is larger than the memory requested, with the difference between the assigned memory and the memory request as the internal fragmentation.
Internal Fragmentation Process
In this process,
- CPU processor receives information about the process to be executed from a computer program.
- The primary memory stores the process in the form of a fixed-sized block called a page. These processes include heap, register, code, etc., and the pages here have a role to play in paging, where pages can access and move the data from secondary memory to primary memory.
- A particular memory block in the form of fragmented memory spaces is assigned for the process.
- If the assigned memory block is very large, larger than the process, it leads to memory wastage.
Due to this, the overheads increase, which keeps the used and unused data of the process in check. The internal fragmentation process cannot be eliminated but can definitely be reduced by using a best-fit block to the memory.
Properties
- Storage space is regulated by reserving space for processes in storage systems.
- The useless space is called fixed segments, which utilize an enormous chunk of data from the excessive memory.
- Inner fragmentation cannot be restored here, but overhead space can be increased.
- For example, in dynamic storage allocation, overhead spaces according to the number of elements present can be increased by storage reservoirs to reduce this problem.
External Fragmentation
External fragmentation is a fragmentation type that allows the allocation of enough memory space for a process to completely fit in the blocks of memory, but the space is in a non-contiguous manner for memory fragments, and hence, there is unused memory space that is wasted. Shuffle memory content into a large block of memory, compaction, paging, or segmentation of free space is used to place all free memory into one large block to solve this problem of memory wastage due to unused blocks in external fragmentation. Dynamic relocation is done in order to make compaction feasible.
In this form of fragmentation, when memory is requested for allocating a method, a first-fit and best-fit memory allocation strategy is followed, such that a non-contiguous block but a sufficient enough quantity of memory is assigned to the method.
External Fragmentation Process
In this process,
- CPU scheduling is used to store particular data of a process in the memory.
- The data is randomly stored in the memory.
- If the next process is received, it will take another chunk of memory to be stored during the execution time.
- If the first process is removed, the data in the memory leaves a hole in memory space beside the free memory, leading to memory wastage.
Properties
- Inaccessible space is, in case of this type, stored outside the allocated portions.
- Here, different-sized files are formed, resized, and discarded.
- It cannot schedule memory effectively and hence is disadvantageous for all kinds of systems.
- Unused storage is available but is limited, in terms of fragmented time slices, to meet the software application demands.
- Total unused memory space is used here to answer all the allocation requests received.
- For example, For three consecutive memory blocks, if the middle block is removed, then the memory allocator allocates this middle block for further processes.
Difference between Internal and External Fragmentation
The main differences between internal and external fragmentation are as follows:
CHARACTERISTIC | INTERNAL FRAGMENTATION | EXTERNAL FRAGMENTATION |
Type of memory block square appointed | Fixed-sized memory block square measure is assigned for a process. | Variable-sized memory block square measure is assigned for a method. |
Size of memory block | Large memory block is assigned to a process. | Memory block allocated is sufficient enough for the process. |
Solution of the fragmentation problem | Internal fragmentation problem can be solved by best-fit block. It can be solved by allocating the smallest partition, sufficient enough for the process or method. | Techniques like shuffle memory content can solve this into a large block, compaction, paging or segmentation of free space. |
Type of partitioning |
It shows fixed partitioning where the memory assigns fixed size of partitions to the process before loading it. | It shows dynamic partitioning where the memory assigns variable size of partitions to the process before loading it. |
Size of partitions | Memory is divided into fixed sized partitions or segments called pages. | Memory is divided into variable-sized partitions, where division is based on the size of processes. |
Processes that occur | This fragmentation occurs along with fixed partitioning and paging. | This occurs along with segmentation and dynamic partitioning. |
Size of memory allocated | More memory is allocated than required or requested. | Memory allocated is of same memory space as required by the process. |
Unused memory space | The unused memory space is because of the different sizes of the requested and allocated memory. | The unused memory space is because of the non-contiguous memory fragments or chunks of memory, which are too small for a process. This is also called non-used memory voids. |
Occurrence | It occurs when a process consumes less space than was allocated. | It occurs when a method is removed from the main memory of the OS. |
Comparison between procedure and process | It occurs when procedure is greater than the process or method. | It can be seen when the procedure is withdrawn or removed. |
First-fit and Best-fit | First-fit and best-fit does not occur here | First-fit and Best-fit occur here. |
Summing up
This article discusses the following concepts:
- Fragmentation is the process of division of a particular memory space into smaller segments that leave enough memory unused to store various processes.
- It reduces the efficiency of the OS, leaving unused storage capacity as well as an inadequate amount of memory space.
- There are two types of memory fragmentation which are internal fragmentation and external fragmentation.
- In summary, internal fragmentation pertains to wasted space within allocated blocks due to fixed-size allocation, while external fragmentation involves scattered gaps between allocated blocks, making it challenging to allocate large contiguous blocks of memory or storage. Both types of fragmentation can impact resource utilization and system performance and are important considerations in memory and storage management strategies.
It is important for operating systems and applications to manage fragmentation effectively to ensure optimal performance and efficient resource utilization. Different strategies are used based on the specific requirements and characteristics of the system and storage devices.
Hope this article was helpful. Here are some more that you may like to read:
- Difference Between Primary And Secondary Data.
- Difference between synchronous and asynchronous counter explained
- Advantages And Disadvantages of Java: Analyze The Pros And Cons
- What’s The Difference Between A MAC Address And An IP Address?
Login to continue reading
And access exclusive content, personalized recommendations, and career-boosting opportunities.
Comments
Add comment