Can it fork?
It’s a well-known fact that Linux (by default) overcommits memory, meaning that allocating memory via e.g. malloc
practically never fails (this behavior is configurable via the vm.overcommit_memory
sysctl knob).
This is possible because Linux doesn’t actually allocate any physical memory when a process requests some (e.g. via a mmap
system call). Instead, it just records that the allocation happened in a Kernel data structure, and returns an address the process can use to access this memory later on. The first time (if ever) a process attempts to access memory it allocated, the Linux Kernel will attempt to allocate physical memory for it.
A bit on naming (this will matter later in this post): the entirety of the memory that was allocated by a process (regardless of whether it was ever accessed and is therefore backed by physical memory) is called virtual memory.
The upside of this...