pub trait DeepSizeOf {
// Required method
fn deep_size_of_children(&self, context: &mut Context) -> usize;
// Provided method
fn deep_size_of(&self) -> usize { ... }
}Expand description
A trait for measuring the size of an object and its children
In many cases this is just std::mem::size_of::<T>(), but if
the struct contains a Vec, String, Box, or other allocated object or
reference, then it is the size of the struct, plus the size of the contents
of the object.
Required Methods§
Sourcefn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Returns an estimation of the heap-managed storage of this object. This does not include the size of the object itself.
This is an estimation and not a precise result, because it doesn’t account for allocator’s overhead.
This is an internal function (this shouldn’t be called directly),
and requires a Context to track visited references.
Implementations of this function should only call deep_size_of_children,
and not deep_size_of so that they reference tracking is not reset.
In all other cases, deep_size_of should be called instead of this function.
If a struct and all of its children do not allocate or have references,
this method should return 0, as it cannot have any heap allocated
children. There is a shortcut macro for this implementation,
known_size_of, used like known_deep_size!(0, (), u32, u64); which
generates the impls.
The most common way to use this method, and how the derive works,
is to call this method on each of the structs members and sum the
results, which works as long as all members of the struct implement
DeepSizeOf.
To implement this for a collection type, you should sum the deep sizes of the items of the collection and then add the size of the allocation of the collection itself. This can become much more complicated if the collection has multiple separate allocations.
Here is an example from the implementation of DeepSizeOf for Vec<T>
impl<T> DeepSizeOf for std::vec::Vec<T> where T: DeepSizeOf {
fn deep_size_of_children(&self, context: &mut Context) -> usize {
// Size of heap allocations for each child
self.iter().map(|child| child.deep_size_of_children(context)).sum()
+ self.capacity() * std::mem::size_of::<T>() // Size of Vec's heap allocation
}
}Provided Methods§
Sourcefn deep_size_of(&self) -> usize
fn deep_size_of(&self) -> usize
Returns an estimation of a total size of memory owned by the object, including heap-managed storage.
This is an estimation and not a precise result because it doesn’t account for allocator’s overhead.
use priority_lfu::DeepSizeOf;
let mut map: Vec<(Box<u32>, String)> = Vec::new();
map.push((Box::new(42u32), String::from("Hello World")));
map.push((Box::new(20u32), String::from("Something")));
map.push((Box::new(0u32), String::from("A string")));
map.push((Box::new(255u32), String::from("Dynamically Allocated!")));
assert_eq!(map.deep_size_of(),
std::mem::size_of::<Vec<(Box<u32>, String)>>() +
4 * std::mem::size_of::<(Box<u32>, String)>() +
4 * std::mem::size_of::<u32>() +
11 + 9 + 8 + 22
);Implementations on Foreign Types§
Source§impl DeepSizeOf for IpAddr
impl DeepSizeOf for IpAddr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for SocketAddr
impl DeepSizeOf for SocketAddr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Shutdown
impl DeepSizeOf for Shutdown
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Month
impl DeepSizeOf for Month
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Weekday
impl DeepSizeOf for Weekday
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for bool
impl DeepSizeOf for bool
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for char
impl DeepSizeOf for char
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for f32
impl DeepSizeOf for f32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for f64
impl DeepSizeOf for f64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for i8
impl DeepSizeOf for i8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for i16
impl DeepSizeOf for i16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for i32
impl DeepSizeOf for i32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for i64
impl DeepSizeOf for i64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for i128
impl DeepSizeOf for i128
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for isize
impl DeepSizeOf for isize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for str
impl DeepSizeOf for str
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for u8
impl DeepSizeOf for u8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for u16
impl DeepSizeOf for u16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for u32
impl DeepSizeOf for u32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for u64
impl DeepSizeOf for u64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for u128
impl DeepSizeOf for u128
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for ()
impl DeepSizeOf for ()
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for usize
impl DeepSizeOf for usize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for CString
impl DeepSizeOf for CString
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for String
impl DeepSizeOf for String
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for CStr
impl DeepSizeOf for CStr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Ipv4Addr
impl DeepSizeOf for Ipv4Addr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Ipv6Addr
impl DeepSizeOf for Ipv6Addr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AddrParseError
impl DeepSizeOf for AddrParseError
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for SocketAddrV4
impl DeepSizeOf for SocketAddrV4
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for SocketAddrV6
impl DeepSizeOf for SocketAddrV6
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicBool
impl DeepSizeOf for AtomicBool
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicI8
impl DeepSizeOf for AtomicI8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicI16
impl DeepSizeOf for AtomicI16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicI32
impl DeepSizeOf for AtomicI32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicI64
impl DeepSizeOf for AtomicI64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicIsize
impl DeepSizeOf for AtomicIsize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicU8
impl DeepSizeOf for AtomicU8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicU16
impl DeepSizeOf for AtomicU16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicU32
impl DeepSizeOf for AtomicU32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicU64
impl DeepSizeOf for AtomicU64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for AtomicUsize
impl DeepSizeOf for AtomicUsize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Duration
impl DeepSizeOf for Duration
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for OsStr
impl DeepSizeOf for OsStr
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for OsString
impl DeepSizeOf for OsString
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for TcpListener
impl DeepSizeOf for TcpListener
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for TcpStream
impl DeepSizeOf for TcpStream
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for UdpSocket
impl DeepSizeOf for UdpSocket
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Path
impl DeepSizeOf for Path
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for PathBuf
impl DeepSizeOf for PathBuf
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Instant
impl DeepSizeOf for Instant
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for SystemTime
impl DeepSizeOf for SystemTime
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for SystemTimeError
impl DeepSizeOf for SystemTimeError
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Bytes
impl DeepSizeOf for Bytes
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NaiveDate
impl DeepSizeOf for NaiveDate
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NaiveDateTime
impl DeepSizeOf for NaiveDateTime
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for IsoWeek
impl DeepSizeOf for IsoWeek
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NaiveTime
impl DeepSizeOf for NaiveTime
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for FixedOffset
impl DeepSizeOf for FixedOffset
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Local
impl DeepSizeOf for Local
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Utc
impl DeepSizeOf for Utc
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for LineString
impl DeepSizeOf for LineString
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for MultiLineString
impl DeepSizeOf for MultiLineString
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for MultiPoint
impl DeepSizeOf for MultiPoint
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for MultiPolygon
impl DeepSizeOf for MultiPolygon
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Point
impl DeepSizeOf for Point
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Polygon
impl DeepSizeOf for Polygon
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Regex
impl DeepSizeOf for Regex
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Decimal
impl DeepSizeOf for Decimal
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Uuid
impl DeepSizeOf for Uuid
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroI8
impl DeepSizeOf for NonZeroI8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroI16
impl DeepSizeOf for NonZeroI16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroI32
impl DeepSizeOf for NonZeroI32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroI64
impl DeepSizeOf for NonZeroI64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroI128
impl DeepSizeOf for NonZeroI128
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroIsize
impl DeepSizeOf for NonZeroIsize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroU8
impl DeepSizeOf for NonZeroU8
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroU16
impl DeepSizeOf for NonZeroU16
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroU32
impl DeepSizeOf for NonZeroU32
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroU64
impl DeepSizeOf for NonZeroU64
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroU128
impl DeepSizeOf for NonZeroU128
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for NonZeroUsize
impl DeepSizeOf for NonZeroUsize
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl DeepSizeOf for Duration
impl DeepSizeOf for Duration
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<A> DeepSizeOf for (A,)where
A: DeepSizeOf,
impl<A> DeepSizeOf for (A,)where
A: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B> DeepSizeOf for (A, B)where
A: DeepSizeOf,
B: DeepSizeOf,
impl<A, B> DeepSizeOf for (A, B)where
A: DeepSizeOf,
B: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C> DeepSizeOf for (A, B, C)
impl<A, B, C> DeepSizeOf for (A, B, C)
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D> DeepSizeOf for (A, B, C, D)
impl<A, B, C, D> DeepSizeOf for (A, B, C, D)
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E> DeepSizeOf for (A, B, C, D, E)
impl<A, B, C, D, E> DeepSizeOf for (A, B, C, D, E)
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E, F> DeepSizeOf for (A, B, C, D, E, F)
impl<A, B, C, D, E, F> DeepSizeOf for (A, B, C, D, E, F)
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E, F, G> DeepSizeOf for (A, B, C, D, E, F, G)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
impl<A, B, C, D, E, F, G> DeepSizeOf for (A, B, C, D, E, F, G)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E, F, G, H> DeepSizeOf for (A, B, C, D, E, F, G, H)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
impl<A, B, C, D, E, F, G, H> DeepSizeOf for (A, B, C, D, E, F, G, H)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E, F, G, H, I> DeepSizeOf for (A, B, C, D, E, F, G, H, I)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
I: DeepSizeOf,
impl<A, B, C, D, E, F, G, H, I> DeepSizeOf for (A, B, C, D, E, F, G, H, I)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
I: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<A, B, C, D, E, F, G, H, I, J> DeepSizeOf for (A, B, C, D, E, F, G, H, I, J)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
I: DeepSizeOf,
J: DeepSizeOf,
impl<A, B, C, D, E, F, G, H, I, J> DeepSizeOf for (A, B, C, D, E, F, G, H, I, J)where
A: DeepSizeOf,
B: DeepSizeOf,
C: DeepSizeOf,
D: DeepSizeOf,
E: DeepSizeOf,
F: DeepSizeOf,
G: DeepSizeOf,
H: DeepSizeOf,
I: DeepSizeOf,
J: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K, S> DeepSizeOf for HashSet<K, S>
impl<K, S> DeepSizeOf for HashSet<K, S>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K, S> DeepSizeOf for HashSet<K, S>
impl<K, S> DeepSizeOf for HashSet<K, S>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K, V, S> DeepSizeOf for HashMap<K, V, S>
impl<K, V, S> DeepSizeOf for HashMap<K, V, S>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K, V, S> DeepSizeOf for HashMap<K, V, S>
impl<K, V, S> DeepSizeOf for HashMap<K, V, S>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K: Ord + DeepSizeOf> DeepSizeOf for BTreeSet<K>
impl<K: Ord + DeepSizeOf> DeepSizeOf for BTreeSet<K>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<K: Ord + DeepSizeOf, V: DeepSizeOf> DeepSizeOf for BTreeMap<K, V>
impl<K: Ord + DeepSizeOf, V: DeepSizeOf> DeepSizeOf for BTreeMap<K, V>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<R: DeepSizeOf, E: DeepSizeOf> DeepSizeOf for Result<R, E>
impl<R: DeepSizeOf, E: DeepSizeOf> DeepSizeOf for Result<R, E>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Bound<T>
impl<T> DeepSizeOf for Bound<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T> DeepSizeOf for &Twhere
T: DeepSizeOf + ?Sized,
impl<T> DeepSizeOf for &Twhere
T: DeepSizeOf + ?Sized,
fn deep_size_of_children(&self, _context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for &mut Twhere
T: DeepSizeOf + ?Sized,
impl<T> DeepSizeOf for &mut Twhere
T: DeepSizeOf + ?Sized,
fn deep_size_of_children(&self, _context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for [T]where
T: DeepSizeOf,
impl<T> DeepSizeOf for [T]where
T: DeepSizeOf,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Box<T>where
T: DeepSizeOf + ?Sized,
impl<T> DeepSizeOf for Box<T>where
T: DeepSizeOf + ?Sized,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for LinkedList<T>where
T: DeepSizeOf,
impl<T> DeepSizeOf for LinkedList<T>where
T: DeepSizeOf,
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Sums the size of each child object, assuming the overhead of each node is 2 usize (next, prev)
use priority_lfu::DeepSizeOf;
use std::collections::LinkedList;
let mut list: LinkedList<u8> = LinkedList::new();
for i in 0..12 {
list.push_back(i);
}
list.push_front(13);
assert_eq!(list.deep_size_of(), std::mem::size_of::<LinkedList<u8>>()
+ 13 * 1 + 13 * 2 * 8);Source§impl<T> DeepSizeOf for VecDeque<T>where
T: DeepSizeOf,
impl<T> DeepSizeOf for VecDeque<T>where
T: DeepSizeOf,
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Sums the size of each child object, and then adds the size of the unused capacity.
use priority_lfu::DeepSizeOf;
use std::collections::VecDeque;
let mut vec: VecDeque<u8> = VecDeque::new();
for i in 0..12 {
vec.push_back(i);
}
vec.push_front(13);
// The capacity (15?) plus four usizes (start, end, cap, pointer)
assert_eq!(vec.deep_size_of(), vec.capacity() * 1 + 32);With allocated objects:
use priority_lfu::DeepSizeOf;
use std::collections::VecDeque;
let mut vec: VecDeque<Box<u64>> = VecDeque::new();
for i in 0..12 {
vec.push_back(Box::new(i));
}
vec.push_front(Box::new(13));
// The capacity (15?) * size (8) plus four usizes (start, end, cap, pointer)
// and length (13) * the allocated size of each object
assert_eq!(vec.deep_size_of(), 32 + vec.capacity() * 8 + 13 * 8);Source§impl<T> DeepSizeOf for Rc<T>where
T: DeepSizeOf + ?Sized,
impl<T> DeepSizeOf for Rc<T>where
T: DeepSizeOf + ?Sized,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Weak<T>
impl<T> DeepSizeOf for Weak<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Arc<T>where
T: DeepSizeOf + ?Sized,
impl<T> DeepSizeOf for Arc<T>where
T: DeepSizeOf + ?Sized,
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Weak<T>
impl<T> DeepSizeOf for Weak<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T> DeepSizeOf for Vec<T>where
T: DeepSizeOf,
impl<T> DeepSizeOf for Vec<T>where
T: DeepSizeOf,
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
Sums the size of each child object, and then adds the size of the unused capacity.
use priority_lfu::DeepSizeOf;
let mut vec: Vec<u8> = vec![];
for i in 0..13 {
vec.push(i);
}
// The capacity (16) plus three usizes (len, cap, pointer)
assert_eq!(vec.deep_size_of(), 16 + 24);With allocated objects:
use priority_lfu::DeepSizeOf;
let mut vec: Vec<Box<u64>> = vec![];
for i in 0..13 {
vec.push(Box::new(i));
}
// The capacity (16?) * size (8) plus three usizes (len, cap, pointer)
// and length (13) * the allocated size of each object
assert_eq!(vec.deep_size_of(), 24 + vec.capacity() * 8 + 13 * 8);Source§impl<T> DeepSizeOf for MaybeUninit<T>
impl<T> DeepSizeOf for MaybeUninit<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T: Copy> DeepSizeOf for Cell<T>
impl<T: Copy> DeepSizeOf for Cell<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T: TimeZone> DeepSizeOf for DateTime<T>
impl<T: TimeZone> DeepSizeOf for DateTime<T>
fn deep_size_of_children(&self, _: &mut Context) -> usize
Source§impl<T: DeepSizeOf> DeepSizeOf for Option<T>
impl<T: DeepSizeOf> DeepSizeOf for Option<T>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T: DeepSizeOf> DeepSizeOf for RefCell<T>
impl<T: DeepSizeOf> DeepSizeOf for RefCell<T>
fn deep_size_of_children(&self, context: &mut Context) -> usize
Source§impl<T: DeepSizeOf> DeepSizeOf for Mutex<T>
impl<T: DeepSizeOf> DeepSizeOf for Mutex<T>
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
This locks the Mutex, so it may deadlock; If the mutex is
poisoned, this returns 0
Source§impl<T: DeepSizeOf> DeepSizeOf for RwLock<T>
impl<T: DeepSizeOf> DeepSizeOf for RwLock<T>
Source§fn deep_size_of_children(&self, context: &mut Context) -> usize
fn deep_size_of_children(&self, context: &mut Context) -> usize
This reads the RwLock, so it may deadlock; If the lock is
poisoned, this returns 0