Skip to content
EntityQ1935626· pop 10· linked from 66 articles

In computing, mmap(2) is a POSIX-compliant Unix system call that maps files or devices into memory. It is a method of memory-mapped file I/O. It implements demand paging because file contents are not immediately read from disk and initially use no physical RAM at all. The actual reads from disk are performed after a specific location is accessed, in a lazy manner. After the mapping is no longer needed, the pointers must be unmapped with munmap(2). Protection information—for example, marking mapped regions as executable—can be managed using mprotect(2), and special treatment can be enforced usi

Wikidata facts

Show 1 more fact
Stack Exchange tag
stackoverflow.com/tags/mmap
Sources (1)

via Wikidata · CC0

~6 min read

Article

8 sections
Contents
  • History
  • File-backed and anonymous
  • Memory visibility
  • Example of usage under the C programming language
  • Usage in database implementations
  • See also
  • References
  • Further reading

In computing, mmap(2) is a POSIX-compliant Unix system call that maps files or devices into memory. It is a method of memory-mapped file I/O. It implements demand paging because file contents are not immediately read from disk and initially use no physical RAM at all. The actual reads from disk are performed after a specific location is accessed, in a lazy manner. After the mapping is no longer needed, the pointers must be unmapped with munmap(2). Protection information—for example, marking mapped regions as executable—can be managed using mprotect(2), and special treatment can be enforced using madvise(2).

In Linux, macOS and the BSDs, mmap can create several types of mappings. Other operating systems may only support a subset of these; for example, shared mappings may not be practical in an operating system without a global VFS or I/O cache.

Available in 10 languages

via Wikidata sitelinks · CC0

Connections

Categories