Linux · Systems fluency
How does Linux memory management work in production?
Short answer
Linux uses virtual memory, demand paging, and a page cache, so free memory is not the goal; available memory and reclaim behavior matter. The OOM killer acts when the kernel cannot satisfy allocations under pressure.
Each process sees a virtual address space mapped to physical pages on demand. The kernel reclaims clean file-backed pages from the page cache and may swap out anonymous pages. RSS counts resident pages, but shared pages can make process-level sums overstate real usage; PSS accounts for sharing.
free -h
cat /proc/meminfo | head
ps -eo pid,rss,comm --sort=-rss | head
cat /proc/pressure/memoryNumbers that matter
- free is memory doing nothing; available estimates what can be allocated without swapping
- Buffers and cache are reclaimable and usually healthy on a busy host
- Swap in and out rates indicate actual pressure better than swap usage alone
- OOM score influences which process the kernel kills
- cgroup memory limits constrain a service independently of the host
If a service is OOM-killed, check its cgroup limit, its actual working set, and whether a leak or traffic spike caused growth. Raising the limit without understanding growth only delays the failure.
Follow-ups you should expect
Interviewers use these to check whether the first answer was understanding or memorisation.
- 1Why is low free memory not automatically a problem?
- 2What is the difference between RSS and PSS?
- 3How do you investigate an OOM kill?
- 4What does PSI memory pressure tell you?
Say it in the interview
Linux uses virtual memory and a page cache, so free memory is not the metric to optimize. I look at available memory, swap in and out, and pressure indicators. RSS overcounts shared pages, while PSS accounts for them. For OOM kills I check the cgroup limit and the process working set before changing anything.
Use this as a model, not a script. Saying it in your own words is what makes it survive follow-up pressure.
Related questions
Reading is step one
Now say it out loud.
Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Linux mock interview and get scored feedback on depth, clarity and confidence.