0% found this document useful (0 votes)
13 views11 pages

Memory Management

Memory management
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views11 pages

Memory Management

Memory management
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Memory Management

Memory management in an operating system (OS) is the process of controlling and


coordinating computer memory. It involves allocating memory to different programs
and ensuring that they have enough memory to run efficiently. The main functions of
memory management include:

1. Allocating memory: When a program needs to run, the OS assigns memory


space for it.
2. Tracking memory usage: The OS keeps track of which parts of memory are in
use and which are free.
3. Deallocating memory: After a program finishes running, the OS frees up the
memory so other programs can use it.

Good memory management helps prevent issues like running out of


memory, which can cause programs to crash or slow down the system.
Functions of Memory Management
Memory management plays a critical role in ensuring the efficient use of a
computer’s memory. The key functions of memory management in an operating
system are:
1. Memory Allocation: It assigns memory to various programs and processes when
they need it. This can be done through partitioning, paging, or segmentation to
ensure optimal usage of available memory.
2. Memory Protection: It ensures that one process does not interfere with the
memory allocated to another process. This prevents crashes and protects the data
integrity of running programs.
3. Memory Deallocation: When a program or process finishes, memory management
frees the allocated space so that it can be reused by other programs. This avoids
memory leaks and ensures efficient reuse of memory.
4. Swapping: When the system runs out of RAM, memory management swaps out
inactive parts of programs to the hard drive (virtual memory) and brings them back
when needed. This allows running larger programs than the physical memory can
handle.

5. Fragmentation Handling: Memory management deals with


fragmentation (both internal and external) to make sure memory is used efficiently
and prevent wastage of space.
Partitioning
Partitioning is a technique in memory management where the memory is divided
into fixed or variable-sized sections called partitions. Each partition can hold one
program or process. There are two main types of partitioning

Fixed Partitioning
The memory is divided into a set number of partitions of fixed sizes. Each partition
can only hold one process, and its size is predetermined. However, this can lead to
internal fragmentation, where a process doesn’t use the entire partition, wasting
memory.
Dynamic (Variable) Partitioning
Memory is divided into partitions based on the needs of processes. Partitions are
created dynamically as programs request memory. This helps in reducing internal
fragmentation but can lead to
external fragmentation: where free memory is scattered in small blocks.
In contiguous memory management techniques, the two main types are:
1. Fixed Partitioning (Fixed-Sized Partitioning):
- Memory is divided into fixed-size partitions.
- Each partition is allocated to one process.
- Any unused space in a partition leads to internal fragmentation.
- The number of partitions is fixed, limiting the number of processes that can be in memory at once.

2. Dynamic Partitioning (Variable-Sized Partitioning):

- Memory is divided based on the size of the process.


- Each process is given exactly the amount of memory it requires.
- Over time, this can lead to external fragmentation, where free memory is scattered in small blocks across memory.
- Techniques like compaction may be used to consolidate free space.
Contiguous memory management technique has Three common memory
allocation strategies : First Fit, Best Fit, and Worst Fit.
1. First Fit:
- The system scans memory and allocates the first available block of memory that is large enough to satisfy the process's
requirements.
- This technique is fast, as it does not require checking all available blocks, but it may leave smaller, unusable fragments of
memory.

2. Best Fit:
- The system searches for the smallest available block of memory that is large enough to fulfill the process's requirements.
- This minimizes leftover memory (reducing external fragmentation), but it can lead to slower allocation since the system must
search through all available blocks to find the best match.

3. Worst Fit:
- The system allocates the largest available block of memory to a process.
- The idea is that by leaving large blocks of memory free, future allocations will have more room. However, it often increases
fragmentation by leaving smaller unusable memory chunks.
Numerical on: Fixed Partitioning (Fixed-Sized Partitioning):
Calculate Internal and External Fragmentation for given scenario
Process Required Storage. 200 400 600 500 300 250
P1 375
P2 210
P3 468
P4 491
200 400 600 500 300 250

First Fit

200 400 600 500 300 250

Best Fit
200 400 600 500 300 250

Worst Fit

Calculate Internal and External Fragmentation


Numerical on: Dynamic Partitioning (Variable-Sized Partitioning):
50 150 300 350 600
Process Required Storage.
P1 300
P2 25
P3 125
P4 50

50 150 300 350 600

First Fit
50 150 300 350 600

Best Fit

50 150 300 350 600

Worst Fit

You might also like