Trait parity_util_mem::MallocSizeOf
source · [−]pub trait MallocSizeOf {
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize;
fn constant_size() -> Option<usize>
where
Self: Sized,
{ ... }
}
Expand description
Trait for measuring the “deep” heap usage of a data structure. This is the most commonly-used of the traits.
Required methods
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
Measure the heap usage of all descendant heap-allocated structures, but
not the space taken up by the value itself.
If T::size_of
is a constant, consider implementing constant_size
as well.
Provided methods
fn constant_size() -> Option<usize> where
Self: Sized,
fn constant_size() -> Option<usize> where
Self: Sized,
Used to optimize MallocSizeOf
implementation for collections
like Vec
and HashMap
to avoid iterating over them unnecessarily.
The Self: Sized
bound is for object safety.
Implementations on Foreign Types
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf, TupleElement10: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf, TupleElement10: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf, TupleElement10: MallocSizeOf, TupleElement11: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10, TupleElement11)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf, TupleElement3: MallocSizeOf, TupleElement4: MallocSizeOf, TupleElement5: MallocSizeOf, TupleElement6: MallocSizeOf, TupleElement7: MallocSizeOf, TupleElement8: MallocSizeOf, TupleElement9: MallocSizeOf, TupleElement10: MallocSizeOf, TupleElement11: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2, TupleElement3, TupleElement4, TupleElement5, TupleElement6, TupleElement7, TupleElement8, TupleElement9, TupleElement10, TupleElement11)
If a mutex is stored directly as a member of a data type that is being measured, it is the unique owner of its contents and deserves to be measured.
If a mutex is stored inside of an Arc value as a member of a data type that is being measured, the Arc will not be automatically measured so there is no risk of overcounting the mutex’s contents.
The same reasoning applies to RwLock.