You are on page 1of 12

OS Section 8

(Memory management)

By Eng. : Beshoy Samy


Memory management

 memory management is one of the core


functions of the operating system.

 Memoryis mainly used to store system


and application instructions, data, cache,
etc.
Memory Map

 What we usually call memory capacity,


actually refers to physical memory.
 Physical memory is also called main
memory, and the main memory used by
most computers is dynamic random
access memory (DRAM).
 Only the kernel has direct access to
physical memory.
Virtual address

 The Linux kernel provides each process


with an independent virtual address
space, and this address space is
contiguous.

 In
this way, the process can easily access
memory, more precisely the virtual
memory.
virtual address

 The interior of the virtual address space is


divided into two parts:
 kernel space and user space.
 Processors with different word length
(maximum length of data that a single
CPU instruction can process) have
different address space ranges.
memory shortage

 When memory shortage is found, the


system will reclaim memory through a
series of mechanisms
Recycle

 Recycle the cache, such as using the LRU


(Least Recently Used) algorithm to recycle
the least recently used memory pages;
Reclaim

 Reclaim infrequently accessed memory,


and write infrequently used memory
directly to the disk through the swap
partition;
Kill

 Kill
the process. When the memory is tight,
the system will directly kill the process that
occupies a large amount of memory
through OOM (Out of Memory).
OOM

 The
OOM uses oom_score to score the
memory usage of each process:

 Thelarger the memory consumed by a


process, the larger the oom_score

 The
more CPU a process takes to run, the
smaller the oom_score
Manually adjust OOM
Any Questions?

You might also like