What are memory-mapped files, and what advantages do they offer over regular read/write I/O?

Last updated 5 July 2026

  • A memory-mapped file (via mmap()) maps file contents into virtual memory. Pages load on fault and dirty pages are written back later.

  • Advantages: fewer syscalls, no extra copy into user buffers, lazy loading of only touched pages, and easy sharing between processes.

  • Caveats: durability needs an explicit msync(). I/O errors arrive as faults (e.g. SIGBUS) rather than return codes.

  • https://prachub.com/resources/mmap-interview-questions-copy-on-write-file-truncation-and-page-faults
  • https://www.geeksforgeeks.org/operating-systems/memory-management-interview-questions/
  • https://learn.microsoft.com/en-us/dotnet/standard/io/memory-mapped-files
  • https://comp.anu.edu.au/courses/comp2310/labs/07-mmio/
  • https://dev.to/kherld/memory-mapped-io-for-handling-files-larger-than-ram-4o7k
  • https://mdsohail.dev/blog/a-developer-guide-to-mmap/
  • https://medium.com/@kuldeeparyadotcom/unlocking-performance-real-world-applications-of-mmap-573663028371
  • https://levelup.gitconnected.com/traditional-io-vs-mmap-vs-direct-io-how-disk-access-really-works-3bbd147ca356
All Operating Systems interview questions