Lessons in this course (11)

5. Virtual memory, paging and memory management by the OS

Intermediate★ Must knowLesson 5 of 11

Each process sees its own virtual address space (e.g. 128 TB on 64-bit Windows/Linux). The OS and CPU (MMU) translate virtual addresses to physical RAM in fixed-size pages (usually 4 KB).

  • Isolation: one process can't read another's memory → security and stability.
  • Overcommit: processes can reserve more than physical RAM; pages are loaded only when touched.
  • Page fault: accessing a page not in RAM → the OS loads it (from the page file/swap or the executable on disk). Too many = thrashing (system becomes extremely slow).
  • Memory-mapped files: a file mapped into memory; reading memory reads the file (used by databases and the .NET loader).

Terms you see in Task Manager / monitoring:

TermMeaning
Working setPages of the process currently in physical RAM
Private bytes / commitMemory the process has committed for itself (heap, stacks)
Virtual sizeAll reserved address space (often huge, mostly unused)
Page file / swapDisk area used when RAM is full

Interview tip: "Memory leak in a managed app" usually means objects are still referenced (static lists, event handlers, caches without limits), so the GC is not allowed to free them — the OS sees private bytes grow until out-of-memory or the container is killed.