Skip to main content

MemoryPool

Trait MemoryPool 

Source
pub trait MemoryPool: Send + Sync {
    // Required methods
    fn kind(&self) -> MemoryKind;
    fn alloc(&self, bytes: usize, align: usize) -> Result<Box<dyn Allocation>>;

    // Provided method
    fn trim(&self) { ... }
}
Expand description

Pluggable allocator. Concrete backends register one default pool per device (e.g. CUDA stream-ordered async allocator) plus optional pools for pinned / unified memory.

Required Methods§

Source

fn kind(&self) -> MemoryKind

Source

fn alloc(&self, bytes: usize, align: usize) -> Result<Box<dyn Allocation>>

Allocate bytes aligned to align. Speed-over-safety: the returned allocation is uninitialised.

Provided Methods§

Source

fn trim(&self)

Optional: hint a deallocation watermark. No-op for backends without it.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§