Memory Management 2025
Topic: Memory Management
Memory management is the Operating System function responsible for managing computer’s
internal and external memory.
Memory management is the functionality of an operating system which handles or manages
primary memory and moves processes back and forth between main memory and disk during
execution. Memory management keeps track of each and every memory location, regardless
of either it is allocated to some process or it is free. It checks how much memory is to be
allocated to processes. It decides which process will get memory at what time. It tracks
whenever some memory gets freed or unallocated and correspondingly it updates the status.
An operating system manages computer memory by:-
i) Taking care of allocation and de-allocation of memory spaces/ partitions to
various programs or processes.
ii) keeping track of which parts of memory are currently being used and by whom
iii) Deciding which processes are to be loaded into the main memory when memory
becomes available.
iv) Keeping track of un-used memory spaces.
Note: - Main memory usually has two partitions −
(i) Low Memory − Operating system resides in this memory.
(ii) High Memory − User processes are held in high memory.
The operating system employs the following techniques in managing computer memory:-
1. Single Contiguous allocation
2. Multiple Partition Allocation
3. Paging
4. Segmentation
5. Swapping
©Juliet 2025 Page 1
Memory Management 2025
(1) Single Contiguous allocation: - This is the easiest memory management technique.
In this method, all types of computer's memory except a small portion which is
reserved for the OS is available for one application i.e. RAM size is subdivided into
two memory partitions to only accommodate one user process and the kernel files
thus limiting the user to only execute one task at a time. MS-DOS operating system
allocates memory in this way.
An illustration of single contiguous allocation
RAM capacity
Partition 1: Reserved memory partition (kernel
files)
Partition 2: Used by only one process at a time
Free memory space
Advantages of single Contiguous allocation Method
(i) No special hardware’s and software’s required
(ii) Easy to use and implement
(iii)Entire schemes requires less memory
Limitations of Single Contiguous Method
(i) Memory is not fully utilized.
(ii) Processor time not efficiently utilized
(iii)The user program is limited to the size available in the main memory.
(iv) Generates reduced system throughput.
(v) Some of the allocated memory may be unused depending on the size of the admitted
user process.
©Juliet 2025 Page 2
Memory Management 2025
(2) Multiple Partition Allocation –Fixed (Static) Multiple Partition Allocation Method
In this technique, the main memory is divided into fixed memory partitions of the same size
where each partition should contain only one process. When a partition is free, a process is
selected from the input queue and is loaded into the free partition. When the process
terminates, the partition becomes available for another process.
Each process is loaded into a partition of equal or greater size and is confined to its allocated
partition. However, if there are comparatively small processes with respect to the fixed
partition sizes, this poses a big problem. This results in occupying all partitions with lots of
unoccupied space left. This unoccupied space is known as fragmentation. Within the fixed
partition context, this is known as internal fragmentation (IF). This is because of unused
space created by a process within its allocated partition (internal).
This technique is desirable in multiprogramming environment though the degree of
multiprogramming is bounded by the number of partitions. This method provides a faster
response time and better program security. However, the method leads to internal memory
fragmentation.
Illustration:
Kernel 5KB
Process 1 5KB
Process 2
5KB
Process 3
1KB Non- utilized memory space
Advantages of Fixed Partitioning technique
(i) Easy to implement:-algorithms needed to implement Fixed Partitioning are easy to
implement. It simply requires putting a process into certain partition without focusing
on the emergence of Internal and External Fragmentation.
(ii) Little OS overhead:-Processing of Fixed partitions requires lesser excess and indirect
computational power.
©Juliet 2025 Page 3
Memory Management 2025
Limitations of Fixed Partitioning technique
(i) Internal Fragmentation:-Main memory use is inefficient. Any process, no matter how
small, occupies an entire partition. This can cause internal fragmentation.
Internal fragmentation: - this is wasted space in main memory resulting from
incomplete filling of fixed memory allocations of processes/programs
(ii) External Fragmentation:-The total unused space allocated to various partitions cannot
be used to load the processes in the main memory even though there is space
available.
External fragmentation: - External Fragmentation happens when a dynamic memory
allocation algorithm allocates some memory and a small piece is left over that cannot be
effectively used. If too much external fragmentation occurs, the amount of usable
memory is drastically reduced. Total memory space exists to satisfy a request, but it is not
contiguous.
(iii)Limits process size: - Process of size greater than size of partition in Main Memory
cannot be accommodated. Partition size cannot be varied according to the size of
incoming process’s size.
(3) Dynamic Multiple Partition Allocation Method
In this technique, Main memory is divided in Partitions of variable length and number. Each
Process is allocated exactly as much memory as required. This method provides program/
process security this is because every user process is assigned a separate memory partition.
©Juliet 2025 Page 4
Memory Management 2025
An illustration
Kernel
5 KB
10 KB External fragmentation
Process 1
4 KB
Process 2
Free partition
Explanation: - the memory is partitioned into 3 regions. The first region (lower area) is
reserved for operating system. The remaining two regions are for user programs. Two
partitions are occupied by programs PI, and P2. Only the last partition is free and available
for allocation.
Advantages of Dynamic multiple Partitioning technique
(i) Eliminates internal fragmentation.
(ii) Increases system throughput
(iii) Supports multi-programming
(iv) Processes are not limited to the memory sizes available.
Limitations of dynamic multiple Partitioning technique
(i) Likely to generate External Fragmentation
(ii) Difficult to design and implement
(iii)Requires expensive computing resources e.g. powerful CPU and efficient OSs.
(4) Paging:-Paging is a technique of memory allocation where a process is divided into a
number of fixed size blocks called pages usually 4 kilobytes to 512 kilobytes. Similarly, main
memory is divided into small fixed-sized blocks of (physical) memory called frames and the
©Juliet 2025 Page 5
Memory Management 2025
size of a frame is kept the same as that of a page to have optimum utilization of the main
memory and to avoid external fragmentation. Each page is assigned a separate memory
partition of fixed sizes (frames).
An illustration of paging memory allocation technique
Process Y
Page 1 (10 KB)
Page 2 (10 KB)
Page 3 ( 10 KB)
Process X
Page 1 (7 KB)
Page 2 (7 KB)
Page 3 ( 7 KB)
Allocated Memory space
Partition : Reserved (kernel files)
Page X-1 (7KB) – Frame 1
10 KB
Page X-2 (7 KB)- Frame 2
Page X -3 (7 KB)- Frame 3 10 KB
Page Y- 1 (10KB)- Frame 4
Page Y -2 (10 KB) - Frame 5 10 KB
Page Y -3 (10 KB) - Frame 6
10 KB
Advantages of Paging
(i) It allows efficient memory usage.
(ii) It aids in eliminating external fragmentation.
©Juliet 2025 Page 6
Memory Management 2025
(iii) Paging provides memory protection by preventing unauthorized access.
(iv) Enhances efficient utilization of computer memory
(v) Support multiprogramming
(vi) Paging offers simplified memory management so that the programs need not
worry about the physical memory addresses.
Disadvantages of Paging
(i) Since the pages are of fixed size, there is a possibility for internal fragmentation.
(ii) Page table requires extra memory space; therefore this technique may not be good
for a system having small RAM.
(iii) Too many pages in a physical memory at the same time lead to thrashing.
Thrashing in OS is a phenomenon that occurs in computer operating systems
when the system spends an excessive amount of time swapping data between
physical memory (RAM).
(5) Segmentation: - Segmentation is a memory management technique where a process is
divided into variable lengths (small blocks) called segments. Each segment is allocated to
memory independently. However, unlike paging segments are in variable sizes. The segments
correspond to the logical structure of the process. The process can be loaded into several
portions called partitions (segments that are independently positioned in the memory to
provide efficient utilization of free space).
A segment is a logical grouping of information. Each job address is made up of several
segments but fragmented memory spaces may be combined into a single free area if the job
cannot fit in the available space.
An illustration of segmentation
Process Y
Segment 1 (5kb)
Segment 2 (7 kb)
Segment 3.99 (3kb
©Juliet 2025 Page 7
Memory Management 2025
Allocated memory
Partition 1:Reserved
Partition 2; segment 1
5 KB
Partition 3: segment 2
7 KB
Partition 4: segment 3
4 KB
0.01 KB of non-utilized memory (external fragmentation)
Advantages of segmentation
i) Eliminate internal fragmentation
ii) Enhances efficient utilization of computer memory.
iii) Support multiprogramming
Limitations of segmentation
i) It can lead to external fragmentation.
ii) Requires a large main memory and a powerful CPU (it’s a costly memory
management algorithm).
iii) Difficult to implement.
Difference between Paging and Segmentation
S/N Paging Segmentation
1 Paging divides program into Segmentation divides program into variable size
fixed size pages segments.
2 Paging is faster than Segmentation is slower than paging
segmentation
3 It suffers from internal It suffers from external fragmentation
fragmentation
4 There is no external There is no external fragmentation
fragmentation
©Juliet 2025 Page 8
Memory Management 2025
5 Logical address is divided into Logical address is divided into segment number and
page number and page offset segment offset.
(6)Virtual Memory/ Swapping:-
Swapping is a mechanism in which a process can be swapped temporarily out of memory to a
backing store and then brought back into memory for continued execution. Swapping
mechanism makes use of a swap file.
A swap file is a special section of the hard disk used to store files that cannot fit in the RAM.
The operating system copies as much data as possible into main memory, and leaves the rest
on the disk. When the operating system needs data from the disk, it exchanges a portion of
data in main memory with a portion of data on the disk. Swapping creates a dedicated disk
partition in the hard drive for swapped processes which is called swap space.
Swapping needs a backing store – fast disk large enough to accommodate copies of all
memory images for all users; must provide direct access to these memory images.
Swapping technique allows the execution of a program that may not be completely in
memory. The main visible advantage of the scheme is that programs can be larger than
physical memory.
Though performance is usually affected by swapping process, swapping helps in running
multiple and big processes in parallel and that's the reason Swapping is also known as a
technique for memory compaction.
The total time taken by swapping process includes the time it takes to move the entire process
to a secondary disk and then to copy the process back to memory, as well as the time the
process takes to regain main memory.
©Juliet 2025 Page 9
Memory Management 2025
An illustration of swapping technique
RAM capacity
P1:reserved partition
P2: CPU bound process
Swapped Out
P3: CPU bound process External memory
P4: I/O Bound process
Free partition
Swapped In
Advantages of swapping
i) Swapping in OS helps in achieving the goal of Maximum CPU Utilization.
ii) Swapping ensures proper memory availability for every process that needs to be
executed.
iii) Swapping helps avoid the problem of process starvation means a process should not
take much time for execution so that the next process should be executed.
iv) CPU can perform various tasks simultaneously with the help of swapping so that
processes do not have to wait much longer before execution.
v) Swapping ensures proper RAM (main memory) and virtual memory utilization.
vi) Leads to minimum wastage of CPU time on completion so it can easily be applied to a
priority-based scheduling method to improve its performance
vii) It offers a higher degree of multiprogramming
Limitations of swapping
i) It’s complex to implement
©Juliet 2025 Page 10
Memory Management 2025
ii) Requires high computing resources (powerful CPU, efficient OS and a large HDD
capacity)
iii) If the system deals with power-cut during bulky swapping activity then the user may
lose all the information which is related to the program.
iv) If the swapping method uses an algorithm that is not up to the mark then the number
of page faults can be increased and therefore this decreases the complete performance.
v) There may be inefficiency in a case when there is some common resource used by the
processes that are participating in the swapping process.
Key Memory Management terms
(i) Fixed partition: -Memory is divided into a number of fixed sized partitions. Each
partition may contain exactly one process.
(ii) (ii) Variable partition: - Initially all memory is available for user processes, and
is considered as large block of available memory. When a process arrives and
needs memory, the operating system searches for a memory partition, large
enough for this process and allocates only the needed memory depending on the
size of the user process.
(iii) Internal fragmentation: - this is wasted space in main memory resulting from
incomplete filling of fixed memory allocations of processes/programs.
(iv) External fragmentation: - External Fragmentation happens when a dynamic
memory allocation algorithm allocates some memory and a small piece is left over
that cannot be effectively used. If too much external fragmentation occurs, the
amount of usable memory is drastically reduced. Total memory space exists to
satisfy a request, but it is not contiguous.
(v) Logical Vs Physical address space:-An address generated by the CPU is
commonly referred to as a logical address, whereas an address as seen by the
memory unit (that is, the one loaded into the Memory Address Register –MAR of
the memory) is commonly referred to as a physical address.
©Juliet 2025 Page 11
Memory Management 2025
Requirements of Memory management
Memory management systems on multi-tasking operating systems usually deal with the
following issues:-
i) Relocation: -In systems with virtual memory, programs in memory must be able to reside
in different parts of the memory at different times. This is because there is often not enough
free space in one location of memory to fit the entire program. The virtual memory
management unit must also deal with concurrency. Memory management in the operating
system should therefore be able to relocate programs in memory and handle memory
references and addresses in the code of the program so that they always point to the right
location in memory.
ii) Memory Protection: - Processes should not be able to reference the memory for another
process without permission and it should prevent malicious or malfunctioning code in one
program from interfering with the operation of other running programs.
iii) Sharing: - different processes should be able to share information and therefore access
the same part of memory.
iv) Logical organization: - Programs are often organized in modules. Some of these modules
could be shared between different programs, some are read only and some contain data that
can be modified. The memory management is responsible for handling a logical program
organization that is different from the physical linear address space. One way to arrange this
organization is segmentation.
v) Physical organization: - Memory is usually divided into fast primary storage and slow
secondary storage. Memory management in the operating system handles moving
information between these two levels of memory.
©Juliet 2025 Page 12