pub struct MemoryManagement<Storage> { /* private fields */ }
Expand description
Reserves and keeps track of chunks of memory in the storage, and slices upon these chunks.
Implementations§
Source§impl<Storage: ComputeStorage> MemoryManagement<Storage>
impl<Storage: ComputeStorage> MemoryManagement<Storage>
Sourcepub fn from_configuration(
storage: Storage,
properties: MemoryDeviceProperties,
config: MemoryConfiguration,
) -> Self
pub fn from_configuration( storage: Storage, properties: MemoryDeviceProperties, config: MemoryConfiguration, ) -> Self
Creates the options from device limits.
Sourcepub fn new(
storage: Storage,
pools: Vec<MemoryPoolOptions>,
memory_alignment: u64,
) -> Self
pub fn new( storage: Storage, pools: Vec<MemoryPoolOptions>, memory_alignment: u64, ) -> Self
Creates a new instance using the given storage, merging_strategy strategy and slice strategy.
Sourcepub fn get(&mut self, binding: SliceBinding) -> StorageHandle
pub fn get(&mut self, binding: SliceBinding) -> StorageHandle
Returns the storage from the specified binding
Sourcepub fn get_resource(
&mut self,
binding: SliceBinding,
offset_start: Option<u64>,
offset_end: Option<u64>,
) -> Storage::Resource
pub fn get_resource( &mut self, binding: SliceBinding, offset_start: Option<u64>, offset_end: Option<u64>, ) -> Storage::Resource
Returns the resource from the storage at the specified handle
Sourcepub fn reserve(
&mut self,
size: u64,
exclude: Option<&MemoryLock>,
) -> SliceHandle
pub fn reserve( &mut self, size: u64, exclude: Option<&MemoryLock>, ) -> SliceHandle
Finds a spot in memory for a resource with the given size in bytes, and returns a handle to it
Sourcepub fn alloc(&mut self, size: u64) -> SliceHandle
pub fn alloc(&mut self, size: u64) -> SliceHandle
Bypass the memory allocation algorithm to allocate data directly.
§Notes
Can be useful for servers that want specific control over memory.
Sourcepub fn dealloc(&mut self, _binding: SliceBinding)
pub fn dealloc(&mut self, _binding: SliceBinding)
Bypass the memory allocation algorithm to deallocate data directly.
§Notes
Can be useful for servers that want specific control over memory.
Sourcepub fn storage(&mut self) -> &mut Storage
pub fn storage(&mut self) -> &mut Storage
Fetch the storage used by the memory manager.
§Notes
The storage should probably not be used for allocations since the handles won’t be compatible with the ones provided by the current trait. Prefer using the alloc and dealloc functions.
This is useful if you need to time the deallocations based on async computation, or to change the mode of storage for different reasons.
Sourcepub fn memory_usage(&self) -> MemoryUsage
pub fn memory_usage(&self) -> MemoryUsage
Get the current memory usage.
Sourcepub fn print_memory_usage(&self)
pub fn print_memory_usage(&self)
Print out a report of the current memory usage.