Expand description
Typesize
A library to fetch an accurate estimate of the total memory usage of a value.
The goal of this library is to produce the most accurate estimate possible, however without being deeply
integrated into the entire ecosystem this cannot be possible. This leads to the real goal being to get
“close enough” for getting a sense of memory usage in your program. If one of the TypeSize
implementations built-in could be improved, a PR would be greatly appreciated.
An example usage of this library would be to wrap all the types you want to measure recursively in
the derive::TypeSize
derive macro, and for any types which perform their own heap allocation
to manually implement TypeSize
while overriding the TypeSize::extra_size
method.
Features
Library Support
arrayvec
: ImplementsTypeSize
forArrayVec
of any size.simd_json
: ImplementsTypeSize
forOwnedValue
andStaticNode
, enables halfbrown.halfbrown
: ImplementsTypeSize
forSizedHashMap
, enables hashbrown.dashmap
: ImplementsTypeSize
forDashMap
.serde_json
: ImplementsTypeSize
forserde_json::Value
andserde_json::Map
.hashbrown
: ImplementsTypeSize
forhashbrown::HashMap
.secrecy
: ImplementsTypeSize
forSecret
.chrono
: ImplementsTypeSize
forchrono::DateTime
of anychrono::TimeZone
.time
: ImplementsTypeSize
fortime::OffsetDateTime
.url
: ImplementsTypeSize
forurl::Url
.
Modules
Macros
- Implements
TypeSize
for multiple types based on the return value ofstd::mem::size_of
.
Structs
Traits
- A trait to fetch an accurate estimate of the total memory usage of a value.