pub trait MemoryUsage {
// Provided method
fn heap_usage(&self) -> usize { ... }
}Expand description
For inspecting how much memory a value is using.
This trait specifically measures heap memory. If you want to measure stack memory too, add
mem::size_of_val() to it. (This only really matters for the outermost type in a hierarchy.)
Provided Methods§
Sourcefn heap_usage(&self) -> usize
fn heap_usage(&self) -> usize
The heap memory usage of this type. The default implementation returns 0.
Implementations on Foreign Types§
impl MemoryUsage for bool
impl MemoryUsage for f32
impl MemoryUsage for f64
impl MemoryUsage for i8
impl MemoryUsage for i16
impl MemoryUsage for i32
impl MemoryUsage for i64
impl MemoryUsage for i128
impl MemoryUsage for isize
impl MemoryUsage for str
impl MemoryUsage for u8
impl MemoryUsage for u16
impl MemoryUsage for u32
impl MemoryUsage for u64
impl MemoryUsage for u128
impl MemoryUsage for ()
impl MemoryUsage for usize
Source§impl MemoryUsage for String
impl MemoryUsage for String
fn heap_usage(&self) -> usize
impl MemoryUsage for AtomicUsize
impl MemoryUsage for Total<f32>
Available on crate feature
decorum only.impl MemoryUsage for Total<f64>
Available on crate feature
decorum only.impl MemoryUsage for i256
Available on crate feature
ethnum only.impl MemoryUsage for u256
Available on crate feature
ethnum only.Source§impl<A: Array> MemoryUsage for SmallVec<A>where
A::Item: MemoryUsage,
Available on crate feature smallvec only.
impl<A: Array> MemoryUsage for SmallVec<A>where
A::Item: MemoryUsage,
Available on crate feature
smallvec only.fn heap_usage(&self) -> usize
Source§impl<A: MemoryUsage, B: MemoryUsage> MemoryUsage for (A, B)
impl<A: MemoryUsage, B: MemoryUsage> MemoryUsage for (A, B)
fn heap_usage(&self) -> usize
Source§impl<K: MemoryUsage + Eq + Hash, S: BuildHasher> MemoryUsage for HashSet<K, S>
Available on crate feature hashbrown only.
impl<K: MemoryUsage + Eq + Hash, S: BuildHasher> MemoryUsage for HashSet<K, S>
Available on crate feature
hashbrown only.fn heap_usage(&self) -> usize
Source§impl<K: MemoryUsage + Eq + Hash, V: MemoryUsage, S: BuildHasher> MemoryUsage for HashMap<K, V, S>
Available on crate feature hashbrown only.
impl<K: MemoryUsage + Eq + Hash, V: MemoryUsage, S: BuildHasher> MemoryUsage for HashMap<K, V, S>
Available on crate feature
hashbrown only.