4 ms·
After a fork, does the amount of committed memory increase by the size of the child's allocated virtual memory space? I'm curious how committed memory interact
by gcr 10y ago
After a fork, does the amount of committed memory increase by the size of the child's allocated virtual memory space?
I'm curious how committed memory interacts with COW fork semantics. After all, a child can just overwrite the COW/copy of the memory it inherited from its parent without allocating anything else.
- haldean 10y agoNo, all of the child's memory mappings are shared with its parent. Upon write, though, that becomes a new committed mapping; I believe the entire page is copied, so you could end up committing another 4k with a one-byte write from the child.
- gcr 10y agoHm. Then suppose I turn off the OOM killer. What happens to a process that writes to its parent's page if the system has no memory left to commit?
- tedunangst 10y agoCOW is usually a kind of loophole. Most systems only count the pages once (otherwise you'd have to reject the fork, but that becomes inconvenient fast).