Week 12
Week 12
Department of Computer
Science
HITEC University Taxila
Chapter 9: Main Memory
Background
OS 2m 4m 2m 3m 3
b b b b m
b
p p p p p
1 2 3 4 7
Memory Allocation
Memory Allocation
OS
8 MB
8 MB
8 MB
Memory Allocation
2 MB
10 MB
4 MB
4 MB
Memory Allocation
● Compaction:
● Compaction is a technique to collect all
the free memory present in form of
fragments into one large chunk of
free memory,
● which can be used to run other processes.
● Reduce external fragmentation by
compaction
● Move all the processes towards one end of
the memory and all the available free
space towards the other end of the
memory so that it becomes contiguous.
● Compaction is possible only if relocation is
dynamic, and is done at execution time
Memory Allocation
● Advantages of Compaction:
● Reduces external fragmentation
● Memory becomes contagious
● More processes can be loaded to
memory
● Disadvantages of Compaction:
● A huge amount of time is wasted in
performing compaction.
● CPU sits idle for a long time.
Memory Allocation