pub struct MemoryAccountant { /* private fields */ }Expand description
Per-class memory usage bookkeeping.
O(1) allocate/deallocate and cheap snapshots; safe to share via Mutex
since these sit behind the crate::memory::MemoryManager handle.
Implementations§
Source§impl MemoryAccountant
impl MemoryAccountant
Sourcepub fn allocate(&self, attr: MemoryAttribution, amount: u64)
pub fn allocate(&self, attr: MemoryAttribution, amount: u64)
Attribute amount bytes to attr.
Sourcepub fn deallocate(&self, attr: MemoryAttribution, amount: u64)
pub fn deallocate(&self, attr: MemoryAttribution, amount: u64)
Release amount bytes attributed to attr (saturates per-class so an
over-release can never make totals negative).
Sourcepub fn class_usage(&self, class: MemoryAccountingClass) -> u64
pub fn class_usage(&self, class: MemoryAccountingClass) -> u64
Attributed bytes for one class (0 if never allocated).
Sourcepub fn snapshot(&self) -> Vec<(MemoryAccountingClass, u64)>
pub fn snapshot(&self) -> Vec<(MemoryAccountingClass, u64)>
Snapshot of (class, bytes) for reporting, non-zero classes only.
Trait Implementations§
Source§impl Debug for MemoryAccountant
impl Debug for MemoryAccountant
Source§impl Default for MemoryAccountant
impl Default for MemoryAccountant
Source§fn default() -> MemoryAccountant
fn default() -> MemoryAccountant
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for MemoryAccountant
impl RefUnwindSafe for MemoryAccountant
impl Send for MemoryAccountant
impl Sync for MemoryAccountant
impl Unpin for MemoryAccountant
impl UnsafeUnpin for MemoryAccountant
impl UnwindSafe for MemoryAccountant
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more