pub struct ChunkAllocator<'a, const CHUNK_SIZE: usize = DEFAULT_CHUNK_SIZE> { /* private fields */ }
Expand description

Low-level chunk allocator that operates on the provided backing memory. Allocates memory with a variant of the strategies next-fit and best-fit.

The default chunk size is DEFAULT_CHUNK_SIZE. A large chunk size has the negative impact that small allocations will consume at least one chunk. A small chunk size has the negative impact that the allocation may take slightly longer.

Implementations

Returns the used chunk size.

Creates a new allocator object. Verifies that the provided memory has the correct properties. Zeroes the bitmap.

  • heap length must be a multiple of CHUNK_SIZE
  • the heap must be not empty
  • the bitmap must match the number of chunks

It is recommended that the heap and the bitmap both start at page-aligned addresses for better performance and to enable a faster search for correctly aligned addresses.

Version of Self::new that panics instead of returning a result. Useful for globally static versions of this type. The panic will happen during compile time and not during run time. Self::new can’t be used in such scenarious because unwrap() on the Result is not a const function.

Capacity in bytes of the allocator.

Returns number of chunks.

Returns the current memory usage in percentage.

Safety

Unsafe if memory gets de-allocated that is still in use.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.