To Work with a Memory mapped File
Daniela Paschall edited this page 1 week ago


A memory-mapped file contains the contents of a file in digital memory. This mapping between a file and memory house permits an software, including multiple processes, to modify the file by studying and writing directly to the Memory Wave. You should utilize managed code to entry memory-mapped information in the identical way that native Home windows capabilities entry memory-mapped information, as described in Managing Memory-Mapped Recordsdata. Persisted recordsdata are memory-mapped files that are associated with a source file on a disk. When the final course of has completed working with the file, the information is saved to the supply file on the disk. These memory-mapped files are appropriate for working with extraordinarily massive source files. Non-persisted recordsdata are memory-mapped files that are not associated with a file on a disk. When the final course of has completed working with the file, the info is lost and the file is reclaimed by garbage collection. These files are suitable for creating shared memory for inter-course of communications (IPC).


Memory-mapped files could be shared across multiple processes. Processes can map to the identical memory-mapped file by utilizing a standard identify that’s assigned by the method that created the file. To work with a Memory Wave System-mapped file, you need to create a view of the whole memory-mapped file or part of it. You can too create multiple views to the same part of the memory-mapped file, thereby creating concurrent memory. For two views to remain concurrent, they must be created from the identical memory-mapped file. Multiple views may also be vital if the file is better than the size of the application’s logical memory house obtainable for memory mapping (2 GB on a 32-bit laptop). There are two sorts of views: stream access view and random entry view. Use stream access views for sequential entry to a file