#memory #optimization #derive

no-std typesize

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

11 releases

0.1.10 Nov 4, 2024
0.1.9 Sep 7, 2024
0.1.8 Aug 27, 2024
0.1.7 Apr 2, 2024
0.1.3 Nov 29, 2023

#419 in Development tools

Download history 9177/week @ 2024-08-16 17520/week @ 2024-08-23 11052/week @ 2024-08-30 16789/week @ 2024-09-06 7297/week @ 2024-09-13 15786/week @ 2024-09-20 21265/week @ 2024-09-27 6840/week @ 2024-10-04 15406/week @ 2024-10-11 15465/week @ 2024-10-18 13140/week @ 2024-10-25 9459/week @ 2024-11-01 20104/week @ 2024-11-08 42017/week @ 2024-11-15 13175/week @ 2024-11-22 20336/week @ 2024-11-29

96,426 downloads per month
Used in 11 crates (6 directly)

MIT license

39KB
799 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.2–8MB
~71K SLoC