#memory-mapping #physical-memory #memory-map #virtual-memory #memory #process-memory #mapping

mmap-rs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process

7 releases (breaking)

0.6.1 Jan 22, 2024
0.6.0 Jun 20, 2023
0.5.0 Mar 4, 2023
0.4.0 Sep 12, 2022
0.1.0 Oct 27, 2021

#61 in Memory management

Download history 728/week @ 2024-08-17 735/week @ 2024-08-24 927/week @ 2024-08-31 1018/week @ 2024-09-07 1424/week @ 2024-09-14 1887/week @ 2024-09-21 1602/week @ 2024-09-28 1997/week @ 2024-10-05 2001/week @ 2024-10-12 1933/week @ 2024-10-19 1843/week @ 2024-10-26 1744/week @ 2024-11-02 2472/week @ 2024-11-09 1680/week @ 2024-11-16 2146/week @ 2024-11-23 1296/week @ 2024-11-30

7,957 downloads per month
Used in 31 crates (11 directly)

Apache-2.0 OR MIT

120KB
2.5K SLoC

mmap-rs

CI Crates.io Docs

A cross-platform and safe Rust API to create and manage memory mappings in the virtual address space of the calling process. This crate can be used to create both file mappings and anonymous mappings. In addition, this crate supports the use of features such as huge pages, locking physical memory, etc. on platforms where those features are available. Furthermore, this crate allows you to enumerate the memory mappings of a process.

Changelog

View CHANGELOG.

Rust version requirements (MSRV)

mmap-rs supports rustc version 1.67 or greater since version 0.6.1.

Supported Platforms

Tier 1 (builds and tests are run in CI):

  • x86_64-pc-windows-msvc
  • x86_64-unknown-linux-gnu
  • i686-unknown-linux-gnu
  • aarch64-unknown-linux-gnu
  • armv7a-unknown-linux-gnueabihf
  • x86_64-apple-darwin
  • x86_64-unknown-freebsd

Tier 2 (builds are run in CI):

  • i686-pc-windows-msvc
  • aarch64-pc-windows-msvc
  • aarch64-linux-android
  • armv7-linux-androideabi
  • x86_64-linux-android
  • i686-linux-android
  • aarch64-apple-ios

Tier 3 (no CI, but should work):

  • aarch64-apple-darwin
  • x86_64-apple-ios
  • i686-unknown-freebsd

Features

  • Anonymous memory maps.
  • File-backed memory maps (unsafe - see documentation for details).
  • Copy-on-write vs. shared memory maps.
  • Inaccessible memory maps (using PROT_NONE and PAGE_NOACCESS).
  • Read-only memory maps.
  • Read-write memory maps.
  • Executable memory maps.
  • RWX memory maps for JIT purposes (unsafe - see documentation for details).
  • Portable instruction cache flushing.
  • Synchronous and asynchronous flushing.
  • Support for locking physical memory.
  • Huge page support.
  • Stack support (also known as MAP_STACK on Unix).
  • Support to exclude memory maps from core dumps (on Unix only).
  • Reserve memory mappings, rather than directly committing them.
  • Split and merge memory mappings.
  • Query the memory areas of the current/a given process (for a given address or address range).

Dependencies

~3–40MB
~630K SLoC