Virtual Memory
Virtual Memory
Memory
Presented by DEPT of IT
Team Members
Simran Mondal - 10800222019
Moupiya Das - 10800222020
Dhruvbayan Banerjee - 10800222021
1 Introduction
8 Conclusion
INTRODUCTIO
Virtual Memory
N
Virtual Memory is a memory management technique where large programs are
divided into smaller parts called pages, allowing only the required pages or
portions of processes to be loaded into the main memory during execution. This
approach enables efficient execution of programs larger than the available
physical memory.
Purpose
• Virtual memory ensures that the available RAM is utilized optimally by
allocating memory only to active processes and using secondary storage for
inactive data.
3 .Swap Space
⚬ A reserved area on the hard disk or SSD used as an extension of RAM.
⚬ When physical memory is full, inactive or less frequently used pages are
moved to swap space.
⚬ This process frees up RAM for active processes, ensuring the system can
continue to run efficiently.
MEMORY MANAGEMENT
TECHNIQUES
In a computer, virtual memory is managed by the Memory Management Unit
(MMU), which is often built into the CPU.
The CPU generates virtual addresses that the MMU translates into physical
addresses.
There are two main types of virtual memory:
• Pagin • Segmentatio
g n
PAGING
Paging divides memory into small, fixed-size blocks called pages. When the computer
runs out of RAM, pages that are not currently in use are moved to the hard drive (or
secondary storage) into an area called a swap space or swap file. The swap file acts as an
extension of the physical RAM. When a page is needed again, it is swapped back into
RAM, a process known as page swapping or paging in. This process ensures that the
operating system (OS) and applications have enough memory to continue running, even
when the available physical memory is limited.
SEGMENTATION
Segmentation is a memory management technique where a program is divided into
variable-sized segments, such as code, data, and stack. Each segment has a base
address and a limit that defines its starting point and size in memory. Unlike paging,
which uses fixed-size blocks, segmentation allows for logical division of memory.
When RAM is full, segments can be swapped to secondary storage, but
segmentation can lead to external fragmentation, making memory management
more complex. Despite its flexibility, segmentation requires careful handling to
avoid wasted memory.
TYPES OF PAGE
REPLACEMENT ALGORITHMS:
Page replacement algorithms are used by the operating system to decide which pages to swap in
and out of memory when a page fault occurs. The goal is to minimize the number of page faults
and maximize system performance.
1.First-In, First-Out (FIFO)
⚬ Description: The simplest algorithm where the oldest page in memory (the first one that
came in) is replaced when a page fault occurs.
⚬ Pros: Easy to implement.
⚬ Cons: It may not be the most efficient since the oldest page might still be in frequent use.
2.Least Recently Used (LRU)
⚬ Description: Replaces the page that has not been used for the longest period of time. It
tries to replace the least useful pages based on recent access patterns.
⚬ Pros: More efficient than FIFO as it better reflects the actual usage patterns.
⚬ Cons: More complex to implement compared to FIFO.
3.Optimal Page Replacement (OPT)
⚬ Description: Replaces the page that will not be used for the longest time in the future. This
is the theoretically optimal strategy for minimizing page faults.
⚬ Pros: Minimizes page faults.
⚬ Cons: Impractical in real-world systems because it requires knowledge of future page
accesses.
ADVANTAGES OF VIRTUAL
MEMORY
1.Efficient Use of RAM
⚬ Virtual memory allows systems to use physical RAM more effectively by swapping
out inactive pages and keeping only necessary pages in memory.
⚬ This optimizes the usage of available memory resources, enabling larger
applications to run on systems with limited RAM.
2.Multitasking Support
⚬ Virtual memory allows multiple programs to run simultaneously by providing each
program with its own virtual address space, even if physical memory is limited.
⚬ This isolation ensures that one program cannot overwrite another’s memory,
increasing security and stability.
3.Prevents Out-of-Memory Errors
⚬ Virtual memory helps avoid out-of-memory errors by utilizing swap space when
RAM is full, allowing systems to handle more processes or larger workloads than
physical memory alone would support.
4.Memory Protection
⚬ It provides memory protection by preventing one process from accessing the
memory allocated to another process. This helps in ensuring the integrity and
security of data.
DISADVANTAGES OF VIRTUAL
MEMORY
1.Performance Overhead
• When a page fault occurs, retrieving pages from secondary storage (e.g., hard disk or SSD) is
significantly slower than accessing RAM, causing a performance penalty.
• Frequent page faults, known as thrashing, can severely degrade system performance.
1.Increased Complexity
• Managing virtual memory adds complexity to the operating system, as it needs to handle
page tables, page replacement algorithms, and swapping between RAM and secondary
storage.
• This can also require additional hardware (e.g., MMU), adding to the overall system cost.
Thrashing :-
Thrashing occurs when a computer's virtual memory system is overwhelmed by frequent page
faults. It happens when the operating system spends more time swapping pages in and out of
physical memory than executing actual processes. This results in a significant slowdown in
system performance.
Applications of Virtual Memory