Overview
framealloc is a deterministic, frame-based memory allocation library for Rust game engines and real-time applications. It provides predictable performance through explicit lifetimes and scales seamlessly from single-threaded to multi-threaded workloads.
Not a general-purpose allocator replacement. Purpose-built for game engines, renderers, simulations, and real-time systems.
Key Capabilities
| Capability | Description |
|---|---|
| Frame Arenas | Lock-free bump allocation, reset per frame |
| Object Pools | O(1) reuse for small, frequent allocations |
| Thread Coordination | Explicit transfers, barriers, per-thread budgets |
| Static Analysis | cargo fa catches memory mistakes at build time |
| Runtime Diagnostics | Behavior filter detects pattern violations |
Features
Core Allocation
use ;
let alloc = new;
loop
Frame Retention & Promotion
// Keep frame data beyond frame boundary
let navmesh = alloc.;
// Get promoted allocations at frame end
let promotions = alloc.end_frame_with_promotions;
Thread Coordination (v0.6.0)
// Explicit cross-thread transfers
let handle = alloc.frame_box_for_transfer;
worker_channel.send;
// Receiver: let data = handle.receive();
// Frame barriers for deterministic sync
let barrier = new;
barrier.signal_frame_complete;
barrier.wait_all;
// Per-thread budgets
alloc.set_thread_frame_budget;
Runtime Behavior Filter
// Opt-in runtime detection of allocation pattern issues
alloc.enable_behavior_filter;
// After running...
let report = alloc.behavior_report;
for issue in &report.issues
Static Analysis
cargo-fa is a companion tool that detects memory intent violations before runtime.
Installation
Usage
# Check specific categories
# Run all checks
# CI integration
Filtering
Subcommands
Diagnostic Categories
| Range | Category | Examples |
|---|---|---|
| FA2xx | Threading | Cross-thread access, barrier mismatch, budget missing |
| FA3xx | Budgets | Unbounded allocation loops |
| FA6xx | Lifetime | Frame escape, hot loops, missing boundaries |
| FA7xx | Async | Allocation across await, closure capture |
| FA8xx | Architecture | Tag mismatch, unknown tags |
Quick Start
Basic Usage
use ;
Bevy Integration
use *;
use SmartAllocPlugin;
Cargo Features
| Feature | Description |
|---|---|
bevy |
Bevy ECS plugin integration |
parking_lot |
Faster mutex implementation |
debug |
Memory poisoning, allocation backtraces |
tracy |
Tracy profiler integration |
nightly |
std::alloc::Allocator trait support |
diagnostics |
Enhanced runtime diagnostics |
memory_filter |
Behavior filter for pattern detection |
Performance
Allocation priority minimizes latency:
- Frame arena — Bump pointer increment, no synchronization
- Thread-local pools — Free list pop, no contention
- Global pool refill — Mutex-protected, batched
- System heap — Fallback for oversized allocations
In typical game workloads, 90%+ of allocations hit the frame arena path.
Documentation
| Resource | Description |
|---|---|
| API Docs | Generated API documentation |
| TECHNICAL.md | Architecture and implementation details |
| CHANGELOG.md | Version history and migration guides |
License
Licensed under either of:
at your option.