4 ms·
In a sense it does. Page tables would need to be copied.
by enedil 4y ago
In a sense it does. Page tables would need to be copied.
- jacquesm 4y agoYes, but they all point to the same pages. The tables take up a small fraction of the memory of the pages themselves.
- enedil 4y agoBut large fraction, if all you do afterwards is an exec call. Given 8 bytes per page table entry and 4k pages, it's 1/512 memory wasted. So if your process uses 8GB, it's 16MB. Still takes noticeable time if you spawn often.
- jacquesm 4y agoI've never had the page tables be the cause of out of memory issues. Besides the fact that they are usually pre-allocated to avoid recursive page faults, but nothing would stop you from making the page tables themselves also copy-on-write during a fork.
- lxgr 4y agoAren't page tables nested? I don't know if any OS or hardware architecture actually supports it, but I could imagine the parent-level page table being virtual and copy-on-write itself.