Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Process Memory in Practice: mmap, Copy-on-Write, Shared Memory and Container Memory Limits
A process gets memory from the OS with mmap and VirtualAlloc; file-backed pages are shared between processes, copied on write, and in a container the .NET GC caps its heap at 75% of the cgroup limit. We measure a managed allocation in a 256 MB container ending in a catchable OutOfMemoryException at 189 MB instead of OOMKilled, a shared file being counted twice across two processes' RSS, and DATAS cutting Server GC's memory from 593 MB to 167 MB.
Virtual Memory: Pages, Page Tables, the TLB and Page Faults
Virtual memory gives every process its own address space and translates addresses to physical memory page by page; reserving a range and giving it RAM are separate steps, and RAM arrives only when a page is touched. We measure a 512 MB allocation adding 3 MB of resident memory, then 513 MB and 131 thousand minor faults once touched, and show that .NET's 17 GB VIRT is the GC reserve and that a 256 MB container accepts a 1 GB allocation and is then killed by the OOM killer.