3 ms·
Zeroing the pages is not nessisarily the bottleneck here, as Windows has a background thread that will zero memory as it is freed. The problem is the initial al
by MarkSweep 10y ago
Zeroing the pages is not nessisarily the bottleneck here, as Windows has a background thread that will zero memory as it is freed. The problem is the initial allocation just sets up the virtual address space without backing those virtual pages with physical pages. Upon accessing the pages for the first time a page fault has to find a physical page to use.
According to MSDN, even when you use MEM_COMMIT: "The function also guarantees that when the caller later initially accesses the memory, the contents will be zero. Actual physical pages are not allocated unless/until the virtual addresses are actually accessed."
https://msdn.microsoft.com/en-us/library/windows/desktop/aa366887(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa3...