memmap2

Cross-platform Rust API for memory-mapped file IO on Unix and Windows

Library
Cargo
v0.9.11
648stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
59/100Fair
Development Activity52
Maintenance28
Community68
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
75/100Good
Architecture80
Code Quality79
Innovation65
Learning Curve76

memmap2 is a cross-platform Rust library for memory-mapped file IO, exposing Mmap and MmapMut types that let a File be mapped into a process’s address space and accessed as a plain byte slice — &[u8] or &mut [u8] — instead of going through explicit read/write syscalls. It is a maintained fork of the original memmap crate, supporting file-backed maps, anonymous maps, copy-on-write maps, read-only maps, synchronous and asynchronous flushing, executable mappings, stack-backed mappings, and (on Linux) huge pages, with platform-specific backends for Unix (via mmap/libc) and Windows (via the Win32 mapping APIs).

Because mapping a file directly into memory avoids the copy overhead of standard read calls and lets the OS page cache manage data transparently, memmap2 is widely used by databases, parsers, and any Rust code that needs to work with large files efficiently — it has become the de facto standard memory-mapping crate in the Rust ecosystem, with hundreds of millions of downloads across dependents ranging from embedded databases to font- and font-rendering libraries.

What You Get

  • Mmap and MmapMut types for read-only and read-write file-backed memory maps, plus MmapOptions for configuring offset, length, and mapping flags
  • Anonymous memory maps not backed by any file, for cases needing raw mapped memory (e.g. as a growable buffer or guarded stack)
  • Copy-on-write mappings so writes to a mapped file are never persisted back to disk
  • Platform-specific backends for Unix (unix.rs, built on libc) and Windows (windows.rs, built on Win32 mapping APIs), plus a stub fallback for other targets
  • Advice APIs (Advice/UncheckedAdvice on Unix) for hinting access patterns to the OS, plus optional huge-page support on Linux

Common Use Cases

  • Parsing or indexing large files (databases, log files, binary formats) without loading the entire contents into a heap-allocated buffer
  • Building embedded/append-only databases or storage engines that rely on the OS page cache instead of custom buffer management
  • Sharing read-only data between processes via a common memory-mapped file
  • High-performance font, archive, or binary-format parsers that want zero-copy slice access to file contents

Under The Hood

Architecture The crate’s public API lives in src/lib.rs (2,375 lines), centered on MmapOptions as a builder and Mmap/MmapMut/MmapRaw as the resulting handle types, all of which Deref/DerefMut to [u8] for slice-like access. Platform differences are isolated behind a mod os indirection (#[cfg_attr(unix, path = "unix.rs")] / windows.rs / stub.rs), so the public types are identical across platforms while the underlying MmapInner implementation swaps per-OS: unix.rs (550 lines) wraps POSIX mmap/munmap/mprotect via libc, windows.rs (545 lines) wraps CreateFileMappingW/MapViewOfFile, and stub.rs provides a non-functional fallback for unsupported targets. src/advice.rs (422 lines) adds Unix-only madvise-based access hints as a separate, optional module. Tech Stack Pure Rust with a thin libc dependency gated to cfg(unix) and an optional stable_deref_trait integration for interop with crates like owning_ref; dev-dependencies (tempfile, owning_ref) support the test suite. Edition 2021, MSRV 1.65, single-crate repository (not a workspace) maintained as a fork of the original danburkert/memmap-rs. Code Quality The crate opts into #![deny(clippy::all, clippy::pedantic)] and #![deny(unsafe_op_in_unsafe_fn)] at the top of lib.rs, a notably strict lint posture for a crate whose core job is wrapping unsafe OS mapping calls; doc comments on Mmap/MmapMut include runnable examples (file.read_to_end + Mmap::map doctest) that double as documentation tests in CI. Given the crate directly wraps unsafe syscalls (mmap, CreateFileMappingW), correctness depends heavily on careful unsafe-block auditing rather than being fully provable through ordinary unit tests, though the examples/ directory (examples/cat.rs) demonstrates realistic usage patterns. API Design The Deref-to-slice design means Mmap/MmapMut behave like ordinary byte slices everywhere a &[u8]/&mut [u8] is expected, minimizing the learning curve for anyone already comfortable with Rust slices; MmapOptions centralizes the more advanced configuration (offset, length, populate, huge pages) behind a builder rather than proliferating constructor variants.

Used by 7 apps in this directory

TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
C++
69%
Apache 2.0

ClickHouse

Databases · Analytics · Data Engineering

49,325

Open-source column-oriented database that delivers real-time analytical queries on petabyte-scale data with millisecond latency.

View details
95
Repo Health
90
Technical
68
Dependency
Built with
C++69%
Python13%
Updated today
Rust
100%
Other

Fluree DB

Databases

445

A temporal, verifiable graph database with git-like branching, integrated vector/text/geo search, and RDF/SPARQL/JSON-LD/openCypher support — benchmarked at 10.4x faster than the next database on the full Wikidata dump.

View details
86
Repo Health
74
Technical
65
Dependency
Built with
Rust100%
Updated yesterday
Rust
100%
Other

Meilisearch

Search

59,012

Lightning-fast hybrid search engine with AI-powered semantic and full-text retrieval for modern applications.

View details
90
Repo Health
88
Technical
68
Dependency
Built with
Rust100%
Updated 5 days ago
Rust
91%
Apache 2.0

Murr

Databases

107

A RocksDB-based NVMe/S3 cache purpose-built for AI inference workloads — a faster Redis replacement optimized for batch, low-latency, zero-copy reads and writes between data pipelines and inference apps.

View details
63
Repo Health
72
Technical
75
Dependency
Built with
Rust91%
Updated 1 months ago
Java
92%
Apache 2.0

QuestDB

Databases · Analytics

17,263

A high-performance, open-source time-series database built for financial market data, IoT telemetry, and real-time analytics, combining a zero-GC Java/C++ core with SIMD-accelerated SQL and a WAL-to-Parquet storage engine.

View details
91
Repo Health
86
Technical
70
Dependency
Built with
Java92%
Updated today
Rust
77%
AGPL 3.0

Spacedrive

File Storage · Collaboration

38,790

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
60
Repo Health
84
Technical
65
Dependency
Built with
Rust77%
TypeScript20%
Updated 3 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search