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
sourceimpl<T: MallocSizeOf> MallocSizeOf for Arc<T>
impl<T: MallocSizeOf> MallocSizeOf for Arc<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl MallocSizeOf for String
impl MallocSizeOf for String
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize
sourceimpl<'a, T: ?Sized> MallocSizeOf for &'a T
impl<'a, T: ?Sized> MallocSizeOf for &'a T
fn size_of(&self, _ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<T: MallocSizeOf + ?Sized> MallocSizeOf for Box<T>
impl<T: MallocSizeOf + ?Sized> MallocSizeOf for Box<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl MallocSizeOf for ()
impl MallocSizeOf for ()
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<TupleElement0: MallocSizeOf> MallocSizeOf for (TupleElement0,)
impl<TupleElement0: MallocSizeOf> MallocSizeOf for (TupleElement0,)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2)
impl<TupleElement0: MallocSizeOf, TupleElement1: MallocSizeOf, TupleElement2: MallocSizeOf> MallocSizeOf for (TupleElement0, TupleElement1, TupleElement2)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<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)
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<T: MallocSizeOf> MallocSizeOf for Option<T>
impl<T: MallocSizeOf> MallocSizeOf for Option<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<T: MallocSizeOf, E: MallocSizeOf> MallocSizeOf for Result<T, E>
impl<T: MallocSizeOf, E: MallocSizeOf> MallocSizeOf for Result<T, E>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<T: MallocSizeOf + Copy> MallocSizeOf for Cell<T>
impl<T: MallocSizeOf + Copy> MallocSizeOf for Cell<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<T: MallocSizeOf> MallocSizeOf for RefCell<T>
impl<T: MallocSizeOf> MallocSizeOf for RefCell<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<'a, B: ?Sized + ToOwned> MallocSizeOf for Cow<'a, B> where
B::Owned: MallocSizeOf,
impl<'a, B: ?Sized + ToOwned> MallocSizeOf for Cow<'a, B> where
B::Owned: MallocSizeOf,
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T: MallocSizeOf> MallocSizeOf for [T]
impl<T: MallocSizeOf> MallocSizeOf for [T]
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T: MallocSizeOf> MallocSizeOf for Vec<T>
impl<T: MallocSizeOf> MallocSizeOf for Vec<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T: MallocSizeOf> MallocSizeOf for VecDeque<T>
impl<T: MallocSizeOf> MallocSizeOf for VecDeque<T>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T, S> MallocSizeOf for HashSet<T, S> where
T: Eq + Hash + MallocSizeOf,
S: BuildHasher,
impl<T, S> MallocSizeOf for HashSet<T, S> where
T: Eq + Hash + MallocSizeOf,
S: BuildHasher,
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<I: MallocSizeOf> MallocSizeOf for Reverse<I>
impl<I: MallocSizeOf> MallocSizeOf for Reverse<I>
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
fn constant_size() -> Option<usize>
sourceimpl<K, V, S> MallocSizeOf for HashMap<K, V, S> where
K: MallocSizeOf,
V: MallocSizeOf,
impl<K, V, S> MallocSizeOf for HashMap<K, V, S> where
K: MallocSizeOf,
V: MallocSizeOf,
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<K, V> MallocSizeOf for BTreeMap<K, V> where
K: MallocSizeOf,
V: MallocSizeOf,
impl<K, V> MallocSizeOf for BTreeMap<K, V> where
K: MallocSizeOf,
V: MallocSizeOf,
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T> MallocSizeOf for BTreeSet<T> where
T: MallocSizeOf,
impl<T> MallocSizeOf for BTreeSet<T> where
T: MallocSizeOf,
fn size_of(&self, ops: &mut MallocSizeOfOps) -> usize
sourceimpl<T: MallocSizeOf> MallocSizeOf for Mutex<T>
impl<T: MallocSizeOf> MallocSizeOf for Mutex<T>
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.