#memory #optimization #derive

no-std typesize

A library to fetch an accurate estimate of the total memory usage of a value

10 releases

0.1.9 Sep 7, 2024
0.1.8 Aug 27, 2024
0.1.7 Apr 2, 2024
0.1.6 Mar 17, 2024
0.1.3 Nov 29, 2023

#502 in Development tools

Download history 8528/week @ 2024-07-09 4173/week @ 2024-07-16 7077/week @ 2024-07-23 6196/week @ 2024-07-30 6934/week @ 2024-08-06 10195/week @ 2024-08-13 13860/week @ 2024-08-20 15722/week @ 2024-08-27 13157/week @ 2024-09-03 12340/week @ 2024-09-10 11405/week @ 2024-09-17 13958/week @ 2024-09-24 18515/week @ 2024-10-01 6274/week @ 2024-10-08 19759/week @ 2024-10-15 13067/week @ 2024-10-22

60,031 downloads per month
Used in 8 crates (5 directly)

MIT license

34KB
692 lines

TypeSize

A library to fetch an accurate estimate of the total memory usage of a value.

See the documentation on docs.rs.


lib.rs:

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.

MSRV

The Minimum Supported Rust Version is of this crate is 1.65, and it is considered breaking to raise this.

This is without any library support features, as those libraries may require a higher MSRV.

Features

Library Support

Dependencies

~0.3–8MB
~68K SLoC