Memory-mapped Files (Windows Embedded CE 6.0)

1/6/2010

A memory-mapped file, or file mapping, is the result of associating file contents with a portion of the virtual address space of a process. It can be used to share a file or memory between two or more processes.

File-mapping objects are not necessarily backed by a file on the disk. You can create a file mapping by passing an open file handle to CreateFileMapping. The data in the mapping is paged back and forth between RAM and the file as you access the mapping. This type of mapping is called a file-backed mapping. You can also create a file mapping without using a file handle. In such a case, the data in the mapping resides entirely in RAM and is never paged out. This type of mapping is called a RAM-backed mapping.

You can use named memory-mapped files as a method of interprocess communication. If you give the file-mapping object a name, other processes can use the name to open handles to the same mapping object. If you do not give the file-mapping object a name, the only way another process can access the mapping is if you use DuplicateHandle to make a new handle to the mapping and pass the handle to the other process.

** Windows Embedded CE supports named and unnamed file-mapping objects. Unnamed files provide a method for interprocess communication and a way to allocate virtual memory regions larger than the 2 GB process size limit.**

See Also

Concepts

Memory Architecture

Other Resources

Memory Mapping a File