memkit

Crates.iomemkit
lib.rsmemkit
version0.1.0-alpha.1
created_at2025-12-27 00:39:10.730052+00
updated_at2025-12-27 00:39:10.730052+00
descriptionDeterministic, intent-driven memory allocation for systems requiring predictable performance
homepage
repositoryhttps://github.com/YelenaTor/memkit
max_upload_size
id2006492
size112,516
YoruXIII (YelenaTor)

documentation

https://docs.rs/memkit

README

memkit

Core CPU memory allocation primitives for the memkit ecosystem.

Version: 0.1.0-alpha.1

Crates.io Documentation License: MPL-2.0

Overview

memkit provides deterministic, intent-driven memory allocation for game engines and real-time applications. It offers predictable performance through explicit lifetimes and zero-cost abstractions.

Features

  • Frame Arenas — O(1) bump allocation, instant bulk reset per frame
  • Object Pools — O(1) allocation/deallocation for small objects
  • Heap Allocation — Tracked heap allocations with statistics
  • Scoped Allocation — RAII-style checkpoint/restore within frames
  • Thread-Local Fast Paths — Per-thread arenas avoid contention

Quick Start

use memkit::{MkAllocator, MkConfig};

let alloc = MkAllocator::new(MkConfig::default());

// Game loop
loop {
    alloc.begin_frame();
    
    // Frame allocations - ultra fast, reset automatically
    let positions = alloc.frame_slice::<[f32; 3]>(1000).unwrap();
    let velocities = alloc.frame_slice::<[f32; 3]>(1000).unwrap();
    
    // Pool allocations - returned to pool on drop
    let entity = alloc.pool_box(Entity::new()).unwrap();
    
    // Scoped allocations
    {
        let _scope = alloc.scope();
        let temp = alloc.frame_box(TempData::new()).unwrap();
        // temp freed when scope drops
    }
    
    alloc.end_frame(); // Instant reset
}

Types

Type Description
MkAllocator Main allocator entry point
MkConfig Allocator configuration
MkFrameBox<T> Frame-allocated box
MkFrameSlice<T> Frame-allocated slice
MkFrameVec<T> Frame-allocated vector
MkPoolBox<T> Pool-allocated box
MkHeapBox<T> Heap-allocated box
MkScope Scoped checkpoint guard

Configuration

let config = MkConfig {
    frame_arena_size: 64 * 1024 * 1024, // 64 MB per thread
    slab_size_classes: vec![16, 32, 64, 128, 256, 512, 1024, 2048, 4096],
    debug_mode: cfg!(debug_assertions),
    ..Default::default()
};

License

This project is licensed under the Mozilla Public License 2.0 - see the LICENSE.md file for details.

Commit count: 0

cargo fmt