External Fragmentation in OS
Last Updated : 20 Aug, 2024
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.
How to Avoid External Fragmentation?
To avoid external fragmentation in an operating system:
- Use Paging or Segmentation: Paging divides memory into fixed-size blocks (pages), eliminating external fragmentation by ensuring memory allocation in uniform units. Segmentation can also help by allowing variable-sized segments, though it may still cause some fragmentation.
- Compaction: Periodically move processes in memory to create larger contiguous blocks of free space, reducing fragmentation.
- Best-fit Allocation: Allocate the smallest sufficient free block to a process, which helps minimize the leftover free space and reduces fragmentation. However, this strategy might still not entirely eliminate fragmentation.
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 1Now suppose Process 1 and Process 2 have been completed, so now there are free places available, as shown in Figure 2.
Figure 2Now, 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 3Causes 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.
Advantages of External Fragmentation
- Flexible Memory Allocation: Systems permitting variable-sized unusable space allocation may also result in outside fragmentation however can also provide flexibility, allowing applications to request unusable extra acceptable to their precise desires in place of being restricted to constant-sized blocks.
- Efficient Use of Memory: In a few instances, outside fragmentation might also end result from efficient use of memory where small gaps are left after deallocation. Although these gaps are fragmented, the memory as an entire is probably better applied in comparison to the usage of constant-sized blocks.
- Simpler Memory Management Algorithms: Some memory control schemes that cause external fragmentation (like first-healthy or satisfactory-suit) are easier and faster to implement, that can reduce overhead and enhance performance, specifically in structures wherein pace is more essential than the memory wastage because of fragmentation.
- Potential for Dynamic Growth: Allowing external fragmentation would possibly help structures where packages can dynamically grow their memory utilization, as these systems allocate memory in various sizes that high-quality match the software's wishes at different degrees.
Disadvantages of External Fragmentation
- Memory Consumption: Small, unusable intervals of memory accumulate, making it difficult to allocate large chunks of memory even if there is sufficient free space
- Reduced Performance: Over time, fragmentation can slow down memory allocation processes, as the system must search for enough free space.
- Need for Constant Wear: To prevent cracking, the system control may need to rotate (compress) repeatedly, which can take time to wear down
- Limits Program Growth : As memory fragmentation occurs, it can prevent the memory usage of programs from expanding, causing inefficiency or corruption
Conclusion
External fragmentation in OS takes place when unusable space is scattered in small, non-contiguous blocks, making it tough to allocate massive unusable space requests. This ends in wasted space, reduced performance, and capacity device inefficiencies. While strategies like compaction can assist, they upload complexity and overhead. Managing outside fragmentation is essential for maintaining efficient unusable space usage in an operating gadget.
Similar Reads
Non-linear Components In electrical circuits, Non-linear Components are electronic devices that need an external power source to operate actively. Non-Linear Components are those that are changed with respect to the voltage and current. Elements that do not follow ohm's law are called Non-linear Components. Non-linear Co
11 min read
Operating System Tutorial An Operating System(OS) is a software that manages and handles hardware and software resources of a computing device. Responsible for managing and controlling all the activities and sharing of computer resources among different running applications.A low-level Software that includes all the basic fu
4 min read
Spring Boot Tutorial Spring Boot is a Java framework that makes it easier to create and run Java applications. It simplifies the configuration and setup process, allowing developers to focus more on writing code for their applications. This Spring Boot Tutorial is a comprehensive guide that covers both basic and advance
10 min read
Class Diagram | Unified Modeling Language (UML) A UML class diagram is a visual tool that represents the structure of a system by showing its classes, attributes, methods, and the relationships between them. It helps everyone involved in a projectâlike developers and designersâunderstand how the system is organized and how its components interact
12 min read
Types of Operating Systems Operating Systems can be categorized according to different criteria like whether an operating system is for mobile devices (examples Android and iOS) or desktop (examples Windows and Linux). Here, we are going to classify based on functionalities an operating system provides.8 Main Operating System
11 min read
Backpropagation in Neural Network Back Propagation is also known as "Backward Propagation of Errors" is a method used to train neural network . Its goal is to reduce the difference between the modelâs predicted output and the actual output by adjusting the weights and biases in the network.It works iteratively to adjust weights and
9 min read
Polymorphism in Java Polymorphism in Java is one of the core concepts in object-oriented programming (OOP) that allows objects to behave differently based on their specific class type. The word polymorphism means having many forms, and it comes from the Greek words poly (many) and morph (forms), this means one entity ca
7 min read
3-Phase Inverter An inverter is a fundamental electrical device designed primarily for the conversion of direct current into alternating current . This versatile device , also known as a variable frequency drive , plays a vital role in a wide range of applications , including variable frequency drives and high power
13 min read
Steady State Response In this article, we are going to discuss the steady-state response. We will see what is steady state response in Time domain analysis. We will then discuss some of the standard test signals used in finding the response of a response. We also discuss the first-order response for different signals. We
9 min read
CTE in SQL In SQL, a Common Table Expression (CTE) is an essential tool for simplifying complex queries and making them more readable. By defining temporary result sets that can be referenced multiple times, a CTE in SQL allows developers to break down complicated logic into manageable parts. CTEs help with hi
6 min read