rusty_alloc-api 2.6.0

Safe Rust surface for the rusty_alloc pure-Rust mimalloc remake: GlobalAlloc, first-class Heap, and the Allocator trait. No unsafe required of callers. MIT.
Documentation
# rusty_alloc-api

The safe Rust surface over [`rusty_alloc`](https://crates.io/crates/rusty_alloc),
a pure-Rust remake of mimalloc that measures at-or-below mimalloc on
instructions retired for real programs (lua 0.96x, perl 0.99x, sqlite 0.995x) and
below jemalloc across the board (lua 0.83x, perl 0.89x, sqlite 0.98x), while
detecting double frees that upstream silently accepts and carrying no data race
on its free path.

**Status: `1.0.0` — the API is frozen.** See the
[`rusty_alloc`](https://crates.io/crates/rusty_alloc) crate page for the
performance evidence and its scope (instruction counts, not wall-clock).

> **Upgrade from 0.3.x or earlier — mandatory.** 0.4.0 fixed three
> platform-independent use-after-frees; treat 0.3.2 and earlier as unsound on
> every target.

## What it gives you

- **`GlobalAlloc`** — drop it in as `#[global_allocator]`.
- **First-class heaps** — create independent heaps, allocate from them, destroy
  them wholesale.
- **`Allocator`** — the standard allocator trait, stable since Rust 1.100,
  for both the global handle and first-class heaps. Behind the
  `allocator-api` feature, so the crate still builds on Rust 1.88.

```rust
use rusty_alloc_api::RustyAlloc;

#[global_allocator]
static ALLOC: RustyAlloc = RustyAlloc;

fn main() {
    let v: Vec<u64> = (0..1000).collect();
    println!("{}", v.len());
}
```

### Collections in a heap (Rust 1.100+)

```toml
rusty_alloc-api = { version = "2", features = ["allocator-api"] }
```

```rust
use rusty_alloc_api::{Heap, RustyAlloc};

// One collection on rusty_alloc, whatever the program's global allocator is.
let mut v = Vec::new_in(RustyAlloc);
v.push(1u64);

// Collections inside a first-class heap: no unsafe, freed automatically,
// and the borrow means none of them can outlive the heap.
let heap = Heap::new_destroyable();
let mut names = Vec::new_in(&heap);
names.push(Box::new_in(String::from("in the heap"), &heap));
```

Rust 1.100 accepts an allocator in `Vec` and `Box`; the other collections
have not been stabilised with one yet. A collection in a heap stays on the
heap's thread (`Vec<T, &Heap>` is not `Send`), and it is a different type
from a plain `Vec<T>`.

## Features

`debug_checks`, `secure`, `profile` — each forwards to the identically-named
feature on `rusty_alloc`.

`allocator-api` — `core::alloc::Allocator` for `RustyAlloc` and `Heap`.
Needs Rust 1.100; without it the crate's minimum is Rust 1.88.

Security: [threat model](https://github.com/remade-with-rust/rusty_alloc/blob/main/docs/threat-model.md)
· [disclosure policy](https://github.com/remade-with-rust/rusty_alloc/blob/main/SECURITY.md).

## The Remade With Rust ecosystem

<!-- ORG BOILERPLATE — keep identical across repos -->

**Remade With Rust** is an initiative by **[Mata Network](https://www.mata.network/)**
to rebuild essential C and C++ tools in Rust — for the memory safety, the
predictable performance, and the freedom of a permissive license. Each project
is a reimplementation, not a fork: same wire protocols and file formats, new
code you can actually depend on.

We build the core to production grade and open-source it so the community can
extend it. No copyleft. No surprises. Just the tools we rely on, made faster and
safer.

| Project | What it is |
|---|---|
| 🎬 **[remade_ffmpeg_rs]https://github.com/Remade-With-Rust/remade_ffmpeg_rs** | **Our FFmpeg alternative.** Drop-in `ffmpeg` and `ffprobe` binaries — demux → decode → filter → encode → mux, rebuilt as composable Rust crates with **zero GPL/LGPL**. Apache-2.0. `rusty_h264` is its H.264 codec. |
| 🧠 **[FFAI]https://github.com/Remade-With-Rust/FFAI** | **Our sister project: media *for* AI.** "The AI media toolkit, remade with rust." Embedded ASR + TTS (**Mercury**), OCR (**Carmenta**) and vision-language captioning (**Argus**) behind an ffmpeg-style, swap-by-name architecture — no Python, no CUDA. MIT OR Apache-2.0. |
| 🌐 **[Mata Network]https://www.mata.network/** | **The home page.** *"Stop sacrificing your privacy for convenience."* Sovereign, self-hostable privacy infrastructure — wallet & identity, password manager, contact manager, and a browser extension that stops information leaking as you browse. Remade With Rust is its open-source arm. |

→ All projects: **[github.com/Remade-With-Rust](https://github.com/Remade-With-Rust)**

<!-- /ORG BOILERPLATE -->

## License

MIT. See `LICENSE` at the repository root.

---

<!-- HARDENING-TABLE:BEGIN generated by use-protection-please — edit docs/plans/use-protection-please.md, not this block -->
## Hardening status

**Tier** standard · **Audited** 2026-08-19 (survey) · **v1.0.0 gates** 12/12 · [Full checklist](https://github.com/remade-with-rust/rusty_alloc/blob/main/crates/rusty_alloc_api/docs/plans/use-protection-please.md)

`███████████████████░` **95%** &nbsp;·&nbsp; 21 Completed · 0 Scheduled · 1 Incomplete · 33 N/A

| Phase | ✅ Completed | 🗓 Scheduled | ⬜ Incomplete | · N/A |
|---|--:|--:|--:|--:|
| 0 — Threat modeling | 1 | 0 | 0 | 1 |
| 1 — Toolchain | 4 | 0 | 0 | 0 |
| 2 — Supply chain | 6 | 0 | 0 | 2 |
| 3 — Code level | 4 | 0 | 0 | 3 |
| 4 — Static analysis | 0 | 0 | 0 | 1 |
| 5 — Dynamic analysis | 1 | 0 | 0 | 2 |
| 6 — Fuzzing and properties | 1 | 0 | 0 | 3 |
| 7 — Formal verification | 0 | 0 | 0 | 1 |
| 8 — Build and binary | 0 | 0 | 0 | 2 |
| 9 — Runtime privilege | 0 | 0 | 0 | 1 |
| 10 — Cryptography | 0 | 0 | 0 | 3 |
| 11 — CI/CD, release, and operations | 4 | 0 | 1 | 0 |
| 12 — Compliance controls | 0 | 0 | 0 | 14 |
| **Total** | **21** | **0** | **1** | **33** |

**Architect** — Tim — Mata Network
<!-- HARDENING-TABLE:END -->