[][src]Crate swim_mem

Dynamic Memory Model

An advanced dynamic memory model that scales from resource-constrained embedded devices to high-performance super computers.

Design goals

The dynamic memory model was designed to meet a strict set of requirements:

Bare metal
No dependence on a system memory allocator; operable out of a statically declared memory region.

Robust
Handle out-of-memory conditions rigorously, and recoverably.

Deterministic
Guarantee constant allocation and deallocation times.

Relocatable
Safely and deterministically move dynamic memory allocations, without the use of a garbage collector.

Scoped
Constrain dynamic memory allocations to their usage context, by statically bounding memory allocator lifetimes.

Safe
Conform to Rust's data-race-free ownership model. Statically prevent common memory management errors; dynamically detect memory leaks, and semantic memory model violations.

Low fragmentation
Prevent memory fragmentation from accruing by relocating and compacting all memory allocations that outlive a usage context.

Good locality
Maximize data locality by recursively allocating and compacting complex data structures into adjacent cache lines.

Low overhead
Only a single pointer size of memory overhead per dynamic allocation.

High performance
Only hundred or so instructions per allocation.

Concurrent
Thread-safe, lock-free algorithms.

Comprehensive
Complete set of smart pointer types, including cycle-safe soft references.

Terminology

Components

The implementation breaks down into five major categories:

Physical memory model
Types that facilitate working with extents of raw memory:

Logical memory model
Traits that generically define the dynamic memory model:

Memory allocators
Concrete Heap and Hold allocator implementations:

Memory leases
Concrete Lease implementations:

Memory residents
Concrete Resident implementations:

Modules

alloc

Dynamic memory allocators and operators.

block

Untyped memory model.

lease

Memory ownership and access model.

resident

Memory usage model.

Macros

addr_space
hold_scope