Struct light_arena::MemoryArena [] [src]

pub struct MemoryArena { /* fields omitted */ }

Provides the backing storage to serve allocations requested by an Allocator.

The MemoryArena allocates blocks of fixed size on demand as its existing blocks get filled by allocation requests. To make allocations in the arena use the Allocator returned by allocator. Only one Allocator can be active for an arena at a time, after the allocator is dropped the space used by its allocations is made available again.

Example

Allocations are made using the allocator and the placement in syntax.

#![feature(placement_in_syntax)]
use light_arena;

let mut arena = light_arena::MemoryArena::new(8);
let alloc = arena.allocator();
// This would overflow the stack without placement new!
let bytes: &[u8] = &alloc <- [0u8; 8 * 1024 * 1024];

Methods

impl MemoryArena
[src]

[src]

Create a new MemoryArena with the requested block size (in MB). The arena will allocate one initial block on creation, and further blocks of block_size_mb size, or larger if needed to meet a large allocation, on demand as allocations are made.

[src]

Get an allocator for the arena. Only a single Allocator can be active for an arena at a time. Upon destruction of the Allocator its allocated data is marked available again.