What is the purpose of placing pages in a swap file using CreateFileMapping?

The CreateFileMapping function can be used to allocate space in the swap file (if the first argument INVALID_HANDLE_VALUE). Then, the allocated space can be mapped to the virtual address space of the process.

Why do I want to do this instead of just using VirtualAlloc ?

It seems that both functions perform almost the same thing. The memory allocated by VirtualAlloc may at some point be pushed into the page file. Why do I need an API that specifically requests that my pages be placed there in the first instance? Why should I be wondering where my personal pages live?

Is this just a hint at the OS regarding my expected memory usage patterns? (That is, the first is a hint to change these pages more aggressively.)

Or is it just a convenient method when working with very large data sets in 32-bit processes? (That is, I can use CreateFileMapping to create> 4Gb distributions, and then a memory card of smaller fragments of space as needed. Using the swap file helps me manually manage my own set of files for "swapping".)

PS. This question is caused by an article I read recently: http://blogs.technet.com/markrussinovich/archive/2008/11/17/3155406.aspx

+3
source share
2 answers

From CreateFileMappingFunction:

A single file mapping object can be shared by multiple processes.

?

+3

. , , . . , . IPC MSDN .

+1

All Articles