Open In App

External Fragmentation in OS

Last Updated : 12 Sep, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Free spaces in the memory, sometimes referred to as fragments, are created whenever a process is loaded or unloaded from the physical memory block. As these regions are not continuous, no process can be given a contiguous allocation of these small memory chunks. As a result, the RAM is squandered and is not available to other processes. This issue is known as fragmentation.

What is External Fragmentation?

External fragmentation refers to the phenomenon where memory becomes separated into little blocks of free space dispersed all through the framework, making it challenging to distribute bigger adjacent blocks of memory to processes. This division of memory happens because of the allocation and deallocation of processes after some time. As processes are stacked and dumped into memory, gaps are left between them, prompting fragmentation.

This fragmentation is a consequence of the dynamic nature of memory allocation and deallocation. As processes are stacked into memory and afterward delivered when they are not generally required, gaps are left between them. Over the long run, these holes collect and can become divided, making the memory be separated into different multiple smaller segments

External fragmentation essentially influences systems that allocate memory to processes dynamically and have changing memory requirements. In such systems, when a cycle demands a specific measure of memory, the memory chief could have to find a solitary coterminous block of memory that matches the mentioned size. Assuming there are just more modest divided blocks accessible, the memory manager can’t satisfy the solicitation, regardless of whether the aggregate sum of free memory is adequate.

Illustrative Example of External Fragmentation

Lets consider a memory space having 4 processes, each of them requires different amount of memory to execute, as you can see in the Figure 1.

Figure 1

Figure 1

Now suppose Process 1 and Process 2 have been completed, so now there are free places available, as shown in Figure 2.

Figure 2

Figure 2

Now, if we want to run another process (Process 5) requiring memory 50 KB, we will not be able to do it, although there is enough memory to run Process 5 as the memory is not contiguous, as shown in Figure 3.

Figure 3

Figure 3

Causes of External Fragmentation

The primary causes of external fragmentation include:

  • Variable Process Sizes: Processes in a computer framework frequently have changing memory prerequisites. As processes are stacked and dumped into memory, the dispensed memory blocks might contrast in size. This prompts holes of fluctuating sizes between apportioned memory blocks.
  • Memory Allocation and Deallocation: When processes are stacked into memory, they possess specific memory blocks. Hence, when a process finishes or is ended, the memory blocks it involved are delivered back to the free memory pool. Be that as it may, these delivered memory blocks probably won’t be adjacent, making holes between dynamic memory blocks. After some time, these holes can become divided, making it hard to track down a solitary coterminous block of memory to distribute to new processes.
  • Non-Uniform Memory Release: In the event that processes discharge memory blocks in a manner that doesn’t necessarily line up with other memory allocations, holes of unpredictable sizes can shape. For example, in the event that a process delivers a block in two dispensed blocks, it can prompt fracture.
  • Memory Allocation Methodologies: Some memory allocation procedures, similar to best fit or worst fit, can worsen fragmentation. Best Fit, for example, looks for the littlest accessible block that can oblige a process, possibly abandoning more modest holes that can collect over the long run.
  • Fixed Partitioning: In frameworks with fixed partitioning, where memory is separated into fixed-sized allotments, the outer fracture can happen on the off chance that processes require memory in sizes that don’t precisely match the segment sizes. This jumble between process memory needs and segment sizes can prompt both outer and inward discontinuity.
  • High Turnover of Processes: Frameworks with regular process stacking and dumping are more defenseless to outer discontinuity. At the point when processes are quickly stacked and taken out, gaps can be left behind in memory, contributing to fragmentation.

Effects of External Fragmentation

External fragmentation can affect an operating system’s exhibition and memory management:

  • Reduced Memory Usage: Regardless of whether there is adequate free memory altogether, the presence of divided free memory blocks makes it try to dispense bigger bordering blocks to processes. This can prompt lower general memory usage.
  • Expanded Allocation Disappointments: The presence of fragmented memory can create circumstances where there is sufficient free memory to oblige a process, however a contiguous block adequately enormous to satisfy the process memory necessities can’t be found. This can bring about allocation disappointments.
  • Slow Memory Access: Recovering information from non-coterminous memory areas takes additional time than getting information put away in bordering memory blocks. This can prompt slower generally speaking system execution, as extra memory management tasks are required.

Solution of External Fragmentation

Below mentioned are the solutions of External Fragmentation that are mentioned below.

1. Memory Compaction

Memory compaction includes rearranging the items in memory to unite free memory hinders and make bigger contiguous memory regions. This is the closely guarded secret:

  • Process Relocation: Dynamic processes are moved nearer together, and the gaps between them are wiped out or limited. This modification plans to make bigger contiguous free memory blocks.
  • Benefits: Memory compaction straightforwardly targets outside fracture. By making bigger contiguous blocks, it guarantees that memory designations have a higher possibility of tracking down reasonable free memory without fracture.
  • Challenges: Memory compaction can be resource-intensive and may make disturbances in dynamic processes during the compaction process. Furthermore, incessant compaction can affect framework execution and responsiveness.

2. Paging

Paging is a memory management method that abstracts physical memory into fixed-size blocks called pages. These pages are then used to store both process information and working framework information structures. Paging oversees discontinuity through the accompanying components:

  • Page Size: Fixed-size pages guarantee that memory portions are made in uniform increments. This lessens the possibility of making little, fragmented gaps.
  • Virtual Memory: Paging empowers virtual memory frameworks, permitting processes to get to memory areas that are not physically contiguous. This abstraction diminishes the effect of outer discontinuity by giving an intelligent layer that is independent of physical memory design.
  • Page Table Management: The working framework keeps up with page tables that map virtual addresses to physical addresses. These tables permit non-contiguous physical memory to be introduced to processes as a contiguous location space.
  • Page Replacement: In virtual memory frameworks, when memory turns out to be scant, pages can be traded among Smash and circle stockpiling. This component improves memory utilization and limits the impact of fracture.
  • Benefits: Paging fundamentally lessens the effect of outside fracture by abstracting physical memory and permitting the working framework to actually oversee memory designation more.
  • Challenges: Paging can acquaint above due with page table management, and unreasonable trading of pages among slam and plate can adversely influence execution.

FAQs on External Fragmentation

Q.1: What is external fragmentation in operating systems?

Answer:

External fragmentation refers to the phenomenon where free memory becomes dispersed in non-contiguous blocks because of the allocation and deallocation of processes. It can prompt the failure to designate memory for new processes, regardless of whether the all out free memory is adequate.

Q.2: What are some common mitigation strategies for external fragmentation?

Answer:

A few procedures are utilized to moderate external fragmentation, including memory compaction, memory allocation algorithms (First Fit, Best Fit, Worst Fit), buddy memory allocation, memory pools, virtual memory systems, garbage collection, and dynamic memory allocation strategies.

Q.3: How does virtual memory help with external fragmentation?

Answer:

Virtual memory systems utilize a blend of RAM and disk storage to give an abstraction layer to memory management. This mitigates external fragmentation by permitting processes to utilize more memory than is physically accessible and paging information among RAM and disk. furthermore, disk storage to give an abstraction layer to memory management. This mitigates external fragmentation by permitting processes to utilize more memory than is physically accessible and paging information among RAM and disk.

Q.4: Which memory allocation algorithm is best for minimizing external fragmentation?

Answer:

The “Best Fit” memory allocation calculation is frequently thought to be compelling for limiting external fragmentation. In any case, the decision of calculation relies upon different elements, including the particular responsibility and framework necessities.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads