8 releases (breaking)
Uses new Rust 2024
| 0.7.0 | Sep 25, 2025 |
|---|---|
| 0.6.1 | Jan 22, 2024 |
| 0.6.0 | Jun 20, 2023 |
| 0.5.0 | Mar 4, 2023 |
| 0.1.0 | Oct 27, 2021 |
#33 in Memory management
39,524 downloads per month
Used in 67 crates
(16 directly)
120KB
2.5K
SLoC
mmap-rs
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
Rust version requirements (MSRV)
mmap-rs supports rustc version 1.85 or greater since version 0.7.
Supported Platforms
Tier 1 (builds and tests are run in CI):
x86_64-pc-windows-msvcx86_64-unknown-linux-gnui686-unknown-linux-gnuaarch64-unknown-linux-gnuarmv7a-unknown-linux-gnueabihfx86_64-apple-darwinx86_64-unknown-freebsd
Tier 2 (builds are run in CI):
i686-pc-windows-msvcaarch64-pc-windows-msvcaarch64-linux-androidarmv7-linux-androideabix86_64-linux-androidi686-linux-androidaarch64-apple-ios
Tier 3 (no CI, but should work):
aarch64-apple-darwinx86_64-apple-iosi686-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_NONEandPAGE_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_STACKon 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–41MB
~561K SLoC