Expand description
A extension trait for allocators to provide a method for deallocating already-zeroed memory.
§Why?
By providing a method for deallocating already-zeroed memory, we allow applications to tell the allocator which free memory is already zeroed. This means that the allocator can often avoid zeroing memory on the allocation critical path, and the zeroing can instead be performed in a background task just before deallocation.
§ZeroAwareAllocator
When the zero_aware_allocator
cargo feature is enabled, this crate provides a
ZeroAwareAllocator
type. This is a layered allocator, wrapping an innner
allocator and adding the tracking of already-zeroed memory on top of it.
§Using Nightly Rust’s Unstable feature(allocator_api)
By default, this crate uses the allocator_api2
crate to polyfill nightly
Rust’s feature(allocator_api)
. You can instead use the nightly
feature(allocator_api)
by disabling the allocator_api2
cargo feature and
enabling the allocator_api
feature. Note that the nightly feature is unstable
and may break semver.
Structs§
- Default
Deallocate Zeroed - A wrapper around an allocator
A
that provides a default implementation ofDeallocateZeroed
that simply forwards the pointer toA::deallocate
. - Mutex
- Similar to
std::sync::Mutex<T>
but built on top ofLockingMechanism
. - Mutex
Guard - Like
std::sync::MutexGuard<T>
but built on top ofLockingMechanism
. - Single
Threaded Locking Mechanism - A single-threaded implementation of
LockingMechanism
. - Zero
Aware Allocator - A memory allocator that keeps track of already-zeroed memory blocks.
- Alloc
Error Experimental - The
AllocError
error indicates an allocation failure that may be due to resource exhaustion or to something wrong when combining the given input arguments with this allocator.
Traits§
- Deallocate
Zeroed - A trait for allocators that support deallocating already-zeroed memory.
- Locking
Mechanism - A trait for providing mutual exclusion.
- Allocator
Experimental - An implementation of
Allocator
can allocate, grow, shrink, and deallocate arbitrary blocks of data described viaLayout
.