pub trait DataSize {
const IS_DYNAMIC: bool;
const STATIC_HEAP_SIZE: usize;
// Required method
fn estimate_heap_size(&self) -> usize;
// Provided method
fn estimate_detailed_heap_size(&self) -> MemUsageNode { ... }
}
Expand description
Indicates that a type knows how to approximate its memory usage.
Required Associated Constants§
sourceconst IS_DYNAMIC: bool
const IS_DYNAMIC: bool
If true
, the type has a heap size that can vary at runtime, depending on the actual value.
sourceconst STATIC_HEAP_SIZE: usize
const STATIC_HEAP_SIZE: usize
The amount of space a value of the type always occupies. If IS_DYNAMIC
is false, this is
the total amount of heap memory occupied by the value. Otherwise this is a lower bound.
Required Methods§
sourcefn estimate_heap_size(&self) -> usize
fn estimate_heap_size(&self) -> usize
Estimates the size of heap memory taken up by this value.
Does not include data on the stack, which is usually determined using mem::size_of
.
Provided Methods§
sourcefn estimate_detailed_heap_size(&self) -> MemUsageNode
fn estimate_detailed_heap_size(&self) -> MemUsageNode
Create a tree of memory estimations.
Similar to estimate_heap_size
, but the returned value is a tree that typically reports
memory used by structs individually.
Requires the detailed
feature to be enabled.