# memkit
<div align="center">
**Deterministic memory allocation for systems requiring predictable performance.**
[](https://crates.io/crates/memkit)
[](https://docs.rs/memkit)
[](https://opensource.org/licenses/MPL-2.0)
[](https://github.com/YelenaTor/memkit/actions)
</div>
---
**memkit** provides intent-driven CPU memory allocation with explicit lifetimes and zero-overhead abstractions. It is designed for high-performance systems where latency spikes are unacceptable and memory behavior must be auditable.
## ⚡ The memkit Advantage
| **Allocation Cost** | O(n) / Varies | **O(1)** | Zero latency spikes |
| **fragmentation** | High over time | **Zero** (Reset) | Stable long-term uptime |
| **Cache Locality** | Random | **Contiguous** | fast iteration & SIMD |
| **Thread Safety** | Locks / Contention | **Lock-Free TLS** | Linear scaling |
| **Cleanup** | Per-object Drop | **Bulk Reset** | Instant frame cleanup |
## 🛡️ Sentinel Mode (New in Beta)
Enable the `sentinel` feature to activate debug-hardened memory verification:
- **Poisoning**: Fills allocated (`0xAA`) and freed (`0xDD`) memory to catch use-after-free bugs.
- **Trace Logging**: Reports allocation hazards to stderr.
- **Leak Detection**: Verifies zero leaks on shutdown.
```toml
[dependencies]
memkit = { version = "0.1.0-beta.1", features = ["sentinel"] }
```
## 🚀 Quick Start
```rust
use memkit::{MkAllocator, MkConfig};
// Standard setup
let alloc = MkAllocator::new(MkConfig::default());
loop {
alloc.begin_frame();
// 1. Frame Allocation: Bump pointer, instant, dropped at end of frame
let buffer = alloc.frame_slice::<f32>(1024).unwrap();
// 2. Scoped Allocation: Temporary workspace within a frame
{
let _scope = alloc.scope();
let temp = alloc.frame_box(TempData::new()).unwrap();
} // 'temp' effectively freed here (head reset)
// 3. Pool Allocation: Stable objects across frames
let component = alloc.pool_box(Component::new()).unwrap();
alloc.end_frame(); // Instant O(1) reset
}
```
## 📦 Ecosystem
| **memkit** | Core allocators & primitives | **Beta** |
| [memkit-gpu](https://crates.io/crates/memkit-gpu) | Type-safe GPU memory management | **Beta** |
| [memkit-co](https://crates.io/crates/memkit-co) | CPU↔GPU transfer coordination | **Beta** |
| [memkit-async](https://crates.io/crates/memkit-async) | Async-aware backpressure & pools | **Beta** |
| [cargo-memlense](https://crates.io/crates/cargo-memlense) | Static analysis linter | **Beta** |
## 🤝 License
Licensed under the **Mozilla Public License 2.0** (MPL-2.0).
See [LICENSE.md](../LICENSE.md) for details.