1 To Work with a Memory mapped File
Catharine Hanigan edited this page 4 weeks ago


A memory-mapped file contains the contents of a file in virtual memory. This mapping between a file and memory house allows an application, together with a number of processes, to switch the file by studying and writing directly to the memory. You need to use managed code to entry memory-mapped information in the identical means that native Windows capabilities entry memory-mapped recordsdata, as described in Managing Memory-Mapped Files. Persisted files are memory-mapped recordsdata that are related to a supply file on a disk. When the last process has finished working with the file, the info is saved to the supply file on the disk. These memory-mapped recordsdata are suitable for working with extraordinarily massive supply information. Non-persisted information are memory-mapped recordsdata that aren't related to a file on a disk. When the final process has finished working with the file, the data is lost and the file is reclaimed by garbage assortment. These files are appropriate for creating shared memory for inter-course of communications (IPC).


Memory-mapped information will be shared throughout multiple processes. Processes can map to the identical memory-mapped file by utilizing a common title that is assigned by the process that created the file. To work with a memory-mapped file, you must create a view of all the memory-mapped file or part of it. You may as well create multiple views to the same part of the memory-mapped file, thereby creating concurrent memory. For 2 views to remain concurrent, they should be created from the same memory-mapped file. Multiple views may also be essential if the file is higher than the scale of the applying's logical memory area accessible for memory mapping (2 GB on a 32-bit computer). There are two varieties of views: stream access view and random entry view. Use stream entry views for sequential entry to a file