Memory Management in Operating System

What is memory management in operating system? Why is it important? What are its functions in OS? Lecture notes of OS.

Memory Management in Operating System

Memory management is an essential aspect of operating systems (OS) as it regulates the allocation and usage of memory resources in a computer system.

The operating system is responsible for managing the available memory, ensuring that programs and processes can run smoothly, and preventing data corruption.

Why Memory Management?

In the mono programming or uni programming system, the main memory is divided into two parts, one for the operating system and another for the job that is currently executing. Consider the following figure.

Memory Management in OS
Memory management in OS

Here partition B is allowed for the user process. But some part of the partition B was wasted. Blocked lines indicate the wastage of memory in the above figure.

What is Memory Management?

In a multiprogramming environment, the userspace divides into several partitions. Each partition is for one process. The task of the subdivision is carried out dynamically by the operating system. That task is called Memory Management in an operating system.

Efficient memory management is possible with multiprogramming. A few processes are in the main memory, and the remaining process is waiting for I/O. That’s why the processor will be idle. Thus memory needs to be allocated efficiently to send as many as processes into it.

Memory management in OS takes place in two main stages: allocation and deallocation. Memory allocation is the process of assigning a portion of memory to a process, while deallocation is the release of that memory back to the system after the process is finished.

This process is essential to keep the system running efficiently, prevent data corruption, and allocate memory resources to applications that require them.

Memory Management Techniques

Memory management in operating systems is crucial for ensuring the efficient and smooth functioning of the system.

The operating system must allocate memory resources effectively and deallocate them efficiently to ensure that applications can run without interruption and data corruption is prevented.

The different memory management techniques used by operating systems are discussed below.

Contiguous Allocation

In this technique, the memory is divided into blocks, and each process is assigned a contiguous block of memory.

This method is simple to implement, but it has several disadvantages, such as external fragmentation, which occurs when the memory is divided into smaller blocks and is not used efficiently.

Segmentation

In this technique, the memory is divided into variable-sized segments, and each segment is assigned to a process.

This method allows for better memory utilization and reduces external fragmentation, but it requires more overhead to manage.

Paging

In this technique, the memory is divided into fixed-sized pages, and each process is assigned a page.

This method provides a high degree of memory utilization and reduces external fragmentation, but it requires more overhead to manage.

Virtual Memory

Virtual memory is a technique used by operating systems to provide a larger address space than the physical memory available on the system.

This technique allows the operating system to temporarily transfer pages of memory to a hard disk when the physical memory is full.

Conclusion

Memory management is an essential aspect of operating systems and requires a balanced approach to ensure optimal utilization of memory resources.

The different memory management techniques used by operating systems provide various advantages and disadvantages, and it is up to the operating system designer to choose the best method based on their specific requirements.