http://qs321.pair.com?node_id=653115


in reply to Re: RFC: Abusing "virtual" memory
in thread RFC: Abusing "virtual" memory

Page faults are not caused when memory is allocated, but when memory is used. And allocated memory is not "commit"ted; it will be swapped out and back in as the OS sees fit, so re-allocating that space can certainly cause plenty of page faults, even if no "new requests to the OS" are made directly.

Excessive page faults causing a system to be very slow happens when there isn't enough physical memory for all of the running processes to have the things they need resident at the same time. Playing games with when memory is allocated is unlikely to make a big difference in such a scenario in my experience.

No transitions form user mode to kernel mode. One page fault.

That seems to nicely sum up your confusion. Page faults happen as interrupts, not as calls from user mode into kernel mode. You cannot prevent page faults by avoiding calling into the kernel. Just about any time you access any byte of memory, a page fault could happen. Even allocating a big chunk of memory with a single call into the OS will surely cause more than one page fault.

- tye