What are memory-mapped files?

What are memory-mapped files?

A memory-mapped file is a type of file that contains the contents of a file in virtual memory. Basically, it allows for mapping between a file and memory space. This is turn allows an application, including multiple processes, to modify the file by reading and writing directly to the memory. Hence, it allows applications to treat the mapped portion as if it were primary memory.

There are two types of memory-mapped files:

Persisted memory-mapped files - associated with a source file on a disk. Here, the data is saved to the source file on the disk after the last process has finished working with the file. Suitable for working with extremely large source files.

Non-persisted memory-mapped files - are not associated with a file on a disk. After the last process has finished working with the file, the data is lost and the file is reclaimed by garbage collection. Suitable for creating shared memory for inter-process communications (IPC).

Add new comment

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.