WorstFit Allocation in Operating Systems (original) (raw)

Last Updated : 15 Jul, 2025

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 can be allocated using four different methods, which are all **contiguous memory allocation techniques:

Each of these techniques offers a unique approach to assigning memory blocks to processes.

Worst-Fit Memory Allocation

In **Worst-Fit Memory Allocation 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.

Algorithm for Worst Fit Memory Management Scheme

**Step 1: Input the list of memory blocks along with their sizes.
**Step 2: Input the list of processes with their sizes.
**Step 3: For each process, check for the largest memory block (i.e., the block with the maximum size) that is large enough to accommodate the process.
**Step 4: If such a block is found, allocate the process to that block and update the block size.
**Step 5: If no suitable block is found, leave the process unallocated and move on to the next process.
**Step 6: Repeat the above steps for all processes.
**Step 7: Stop.

Refer Program for Worst Fit algorithm in Memory Management for implementation

Worst-fit_

worst-fit

**Advantages of Worst-Fit Allocation

**Disadvantages of Worst-Fit Allocation