#memory #optimization #derive

no-std typesize

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

11 releases

new 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

#425 in Development tools

Download history 5934/week @ 2024-07-17 5420/week @ 2024-07-24 6086/week @ 2024-07-31 9602/week @ 2024-08-07 7514/week @ 2024-08-14 16989/week @ 2024-08-21 12840/week @ 2024-08-28 14846/week @ 2024-09-04 11185/week @ 2024-09-11 13502/week @ 2024-09-18 14086/week @ 2024-09-25 15967/week @ 2024-10-02 9939/week @ 2024-10-09 17514/week @ 2024-10-16 12307/week @ 2024-10-23 14287/week @ 2024-10-30

55,312 downloads per month
Used in 8 crates (5 directly)

MIT license

38KB
785 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
~72K SLoC