Open In App

Internal Fragmentation in OS

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

Internal Fragmentation is a problem that occurs due to poor memory allocation and it results in wastage of memory. When a process is loaded into the system it requests memory which is essential for its working. The operating system allocates memory to processes to work with but if the memory happens to be smaller and bigger than the process requirement the extra space goes unused. This small amount of memory unutilization is the major Internal Fragmentation appearing in the Operating System.

Internal Fragmentation

How Internal Fragmentation is Caused?

When a process requests memory for working, most systems allocate the memory in fixed-sized blocks or pages. In most cases, the memory block that is being allocated is bigger than the amount of memory requested by the process. This is the main reason why Internal Fragmentation is caused.

In some scenarios, a constant amount of memory is allocated to every process requesting for memory. Processes that request/require memory less than that of the constant amount end up wasting a good amount of allocated memory. This also ends up causing Internal Fragmentation.

In some systems, memory is managed by tracking the allocated blocks of memory using some data structure ends up creating some memory overhead. This memory which is wasted to store and manage the data structure which is the tracker of the engaged memory ends up in Internal Fragmentation.

Example:

Let’s assume that the system that is being used assigns the memory in blocks of sizes being multiples of 4(like 12, 24, 32,..). In this system when a process P1 requests an amount of memory that is not a multiple of 4, it is assigned a memory block of value of the nearest higher multiple.

Internal Fragmentation

For example, in this system if a process P1 requests a memory of 29kb, as it is not a multiple of 4 the process is assigned a memory of size 32kb as this is a multiple of 4. Now, the process will only use 29kb of memory, and the rest of the memory goes wasted. This wasted memory results in internal fragmentation.

Effect of Internal Fragmentation

Due to Internal Fragmentation various types of effects occurs:

  • Inefficient Memory Utilization: In internal fragmentation, memory wastage is observed in various ways. Due to this, a vast amount of memory goes unutilized, resulting in Inefficient Memory Utilization.
  • Performance lag: Due to the memory scattering across several partially filled memory blocks caused by Internal Fragmentation, the I/O operations increase in number. This results in an increase in data access times and increased lagging in performance.
  • The disintegration of Memory: When the two types of fragmentations internal and external mix up it leads to memory scattering. This phenomenon causes a disintegration in the memory stream which makes it fairly tough for the system to allocate contiguously.
  • Trouble in Virtual Memory Management: Memory paging and memory swapping is the most important operation that helps to operate and manage virtual memory. Partially filled pages lead to page faults during the memory paging which ultimately affects the operations with the virtual memory.

Why Internal Fragmentation is Allowed?

As Internal Fragmentation is nothing but a problem there isn’t any significant advantage that it provides to the system. But there are a couple of things that favor causing it, which are:

  • As the allocation always occurs in a fixed size only the allocation becomes fast and simple.
  • When the overhead calculation for the system is done it outputs to be pretty predictable which in return gives a predictable performance. The overhead calculation is accurate as the overhead caused by the Internal Fragmentation is already well known.

Ways to Avoid Internal Fragmentation

There are several ways to avoid Internal fragmentation. Some of them are mentioned below.

Variable-Sized Allocation Blocks

The system can make blocks of various sizes and use Variable-sized allocation instead of Fixed Size Allocation. Now when the system gets a request for memory allocation, it can assign the best-fit memory block to that particular process. In this way, it can be assured that a minimum amount of memory space is being wasted.

Dynamic Memory Allocation

Instead of using the basic memory allocation system to allocate memory blocks to the processes, dynamic memory allocation methods can be used. Using these methods only a specific amount of memory is assigned to a process and minimal to no memory is wasted in the process.

FAQs on Internal Fragmentation

1. What causes Internal Fragmentation in OS?

Already discussed in this article under “What is Internal Fragmentation?”.

2. Why is important to reduce Internal Fragmentation as much as possible?

It is important to reduce it as it causes the problems elaborated under the “Effect of Internal Fragmentation” given above.

3. Does Internal Fragmentation Affect Virtual Memory?

Internal Fragmentation does affect the virtual memory as it hinders the memory paging and swapping and that mainly affects the management of the virtual memory by OS.

4. What is the difference between Internal Fragmentation and External Fragmentation?

Understand this difference in-depth by referring to: Internal vs External Fragmentation.

5. Is it possible to completely eliminate Internal Fragmentation?

It might not be possible to eliminate Internal Fragmentation completely, there will be some amount always remaining. But by using careful techniques like dynamic memory allocation it can be reduced as much as possible.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads