What Actually Happens Between malloc() and Physical RAM: Virtual Memory, Page Faults, and the MMU
When you call malloc(100 * 1024 * 1024) in C, new byte[100 * 1024 * 1024] in C#, or allocate a massive buffer in Node.js or Go, how much physical RAM did your machine just allocate? Almost every junior developer answers: 100 megabytes. The real answer is zero bytes. Your operating system handed your process a promise written on virtual paper. Not a single transistor in your DRAM sticks holds your…
When you allocate memory in C using malloc(), Node.js with allocate(), or Go's allocation, the OS doesn't immediately give you physical RAM. It simply promises you a chunk of virtual memory. Your process doesn't own any physical RAM yet. The only thing you have is a promise written in virtual memory. If you check how much memory your process is using in tools like top or /proc/self/status, you'll see that virtual memory size has increased by the requested amount, but resident set size (RSS) remains at 0 KB. Physical memory is only assigned when your CPU actually tries to read or write that first byte.
Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.