#memory #optimization #derive

no-std typesize

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

8 releases

0.1.7 Apr 2, 2024
0.1.6 Mar 17, 2024
0.1.5 Jan 1, 2024
0.1.4 Dec 9, 2023
0.1.3 Nov 29, 2023

#440 in Development tools

Download history 2125/week @ 2024-01-06 2641/week @ 2024-01-13 2718/week @ 2024-01-20 1785/week @ 2024-01-27 2128/week @ 2024-02-03 1901/week @ 2024-02-10 2273/week @ 2024-02-17 2070/week @ 2024-02-24 2002/week @ 2024-03-02 2274/week @ 2024-03-09 3539/week @ 2024-03-16 2842/week @ 2024-03-23 3147/week @ 2024-03-30 2785/week @ 2024-04-06 2553/week @ 2024-04-13 2534/week @ 2024-04-20

11,486 downloads per month
Used in 5 crates (4 directly)

MIT license

31KB
609 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–9MB
~70K SLoC