About File Mapping

File mapping is the association of a file's contents with a portion of the virtual address space of a process. The operating system creates a file-mapping object to maintain this association. A file view is the portion of virtual address space that the process uses to access the file's contents. Processes read from and write to the file view using pointers, just as they would with dynamically allocated memory. Processes can also manipulate the file view with the virtual memory function VirtualProtect.

The file-mapping functions in the Microsoft® Win32® application programming interface (API) allow a process to create file-mapping objects and file views to easily access and share data. The following illustration shows the relationship between the file on disk, a file-mapping object, and a file view.

pics/WIN3200000104.gif

The file on disk can be any file that you want to map into memory, or it can be the system pagefile.

The file-mapping object can consist of all or only part of the file. It is backed by the file on disk. This means that when the system swaps out pages of the file-mapping object, any changes made to the file-mapping object are written to the file. When the pages of the file-mapping object are swapped back in, they are restored from the file.

A file view can consist of all or only part of the file-mapping object. A process manipulates the file through the file views. A process can create multiple views for a file-mapping object.

Windows NT: The file views created by each process reside in the virtual address space of that process.

Windows 95: All file views reside in the shared address space. The shared address space exists in the range between 2 and 3 gigabytes in the virtual address space for each process. It contains the 16-bit heap and shared system DLLs, as well as file views.

When multiple processes use the same file-mapping object to create views for a local file, the data is coherent. That is, the views contain identical copies of the file on disk. The file cannot reside on a remote computer if you want to share memory between multiple processes.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database