OSOperating Systems · Lesson 4 of 7
Memory: Virtual, Paged, Shared
Every process believes it has the entire address space to itself. It's lying — or rather, the OS is lying to it, beautifully. Virtual memory is the OS's single best idea.
Addresses your program uses are virtual; hardware translates them to physical RAM through per-process page tables, in 4KB chunks called pages. Consequences: processes can't see each other's memory (isolation), each can lay out its memory the same way (simplicity), and the same physical page can appear in many processes (shared libraries — one copy of libc for a thousand processes).
◆ Note
This is the machinery under every language's memory story: C's malloc asks the kernel for pages and carves them up; Python/Java/JS garbage collectors manage objects inside pages the same way. When a process's RSS climbs and never falls, that's a leak — in any language.
This is the machinery under every language's memory story: C's malloc asks the kernel for pages and carves them up; Python/Java/JS garbage collectors manage objects inside pages the same way. When a process's RSS climbs and never falls, that's a leak — in any language.