ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
Memory management in Linux Raghu Udiyar Technical Support Engineer Red Hat
What is memory? It is just a form of storage
Can a disk be considered memory? Yes, in a way
Only difference is with : Capacity ¨C cost
Latency
Volatile
Hardware CPU registers  -  ~1 cycle
CPU cache (L1, L2..)  -  3 ¨C 14 cycles
RAM (main memory)  -  ~250 cycles
Disk  -  ~40 million cycles
Physical Memory The map provides the physical addresses
These are then taken and divided into  page frames   of 4Kb
E.g. 4Gb  = ~1 million pages
Virtual Memory The system never allocates physical memory directly
Every process has a  virtual  view of the memory
A process will think it is the only task running on the  system
This virtual memory is then mapped to physical  memory using  page tables
Virtual Memory vi bash 2GB Physical Memory Virtual memory
Virtual Memory vi bash 2GB Physical Memory Virtual memory Page Table
Address Space On a 32bit system : 4Gb  :  3 Gb  userspace / 1 Gb kernel space On a 64bit system : 256 TB userspace / 256 TB kernel space
User and Kernel address space Kernel User Kernel User 32bit 64bit 3Gb 1GB 256TB 256TB
Memory Overcommit Allocate more then what is available
malloc(1G) = Ok
memset(1G) = Ok
malloc(4GB)  = Ok
memset(4GB) = -ENOMEM
Kernel almost always grants  Virtual memory

More Related Content

Memory management in Linux