Memory Management in Operating System

In this tutorial, we will learn about memory management in Operating System, Memory Hierarchy, Memory management Strategies etc. Further we will see the partition allocation.

Registers make memory, each register is equal to one storage location (memory location). The capacity of the memory is the total number of bits that memory can store. We can get and put data of the memory by read and write method, respectively.

Memory Hierarchy :

  • Main Memory ( it stores the immediate needed data or instructions)
  • Secondary Storage ( data that are not actively used are stored here)
  • Cache Memory ( most commonly used data or instructions are stored here. Moreover, retrieving data from cache memory takes much less time.)

Memory management Strategies :

1. Fetch strategy – this strategy decides which piece of data to load next.

2. Placement strategy – this helps to place the incoming data in main memory.

3. Replacement strategy – by replacing data we can free up some space to place another data.

Ways of organizing programs in memory :

  • Contiguous memory allocation –  processes must be placed as a single block of contiguous addresses.
  • Non contiguous memory allocation – process can be divided into several segments. We can place them in different part of memory.

Memory Management Techniques :

following are four common memory management techniques ,

A. Single Contiguous Allocation

B. Partitioned Allocation

C. Paging

D. Segmentation .

In this article, we will talk about partitioned allocation, only.

Partitioned Allocation :

If there is more than one partition available for allocation then we have to select any one of them. Now for selecting partition we use different placement strategies .

1. First Fit : 

This technique places the process at the first hole of the sufficient size found. It scans the memory partitions from the beginning and selects the first block that is large enough to hold the process.

Without doubt this strategy is very simple. Most importantly, the execution time is relatively small.

2. Best Fit :

Best fit helps us to find the first smallest but sufficient hole to place the incoming process. It searches through the entire list to find the best partition that leaves the least unused space.

To conclude, the strategy minimizes the wastage of space. It takes long time because it searches through the whole list every time.

3. Worst Fit :

For allocation it chooses the largest partition. Eventually it leaves the most unused space. Worst Fit is exactly opposite of Best fit. It searches the whole list to find the largest blocks and leave another large hole for other processes.

4. Next Fit :

This strategy is similar to first fit. First fit always scans from the beginning. Whereas Next fit scans from the last allocation point.