For both fixed and dynamic memory allocation schemes, the operating system must keep a list of each memory location noting which are free and which are busy. Then as new jobs come into the system, the free partitions must be allocated.
These partitions may be allocated in 4 ways:
1. First-Fit Memory Allocation 2. Best-Fit Memory Allocation 3. Worst-Fit Memory Allocation 4. Next-Fit Memory Allocation
These are Contiguous memory allocation techniques.
Worst-Fit Memory Allocation :
In this allocation technique, the process traverses the whole memory and always search for the largest hole/partition, and then the process is placed in that hole/partition. It is a slow process because it has to traverse the entire memory to search the largest hole.
Here is an example to understand Worst Fit-Allocation –
Here Process P1=30K is allocated with the Worst Fit-Allocation technique, so it traverses the entire memory and selects memory size 400K which is the largest, and hence there is an internal fragmentation of 370K which is very large and so many other processes can also utilize this leftover space.
Advantages of Worst-Fit Allocation :
Since this process chooses the largest hole/partition, therefore there will be large internal fragmentation. Now, this internal fragmentation will be quite big so that other small processes can also be placed in that leftover partition.
Disadvantages of Worst-Fit Allocation :
It is a slow process because it traverses all the partitions in the memory and then selects the largest partition among all the partitions, which is a time-consuming process.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.