#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

#417 in Development tools

Download history 5878/week @ 2024-08-03 10931/week @ 2024-08-10 12204/week @ 2024-08-17 17397/week @ 2024-08-24 10519/week @ 2024-08-31 14332/week @ 2024-09-07 11187/week @ 2024-09-14 12865/week @ 2024-09-21 20450/week @ 2024-09-28 6813/week @ 2024-10-05 18356/week @ 2024-10-12 13058/week @ 2024-10-19 15916/week @ 2024-10-26 5885/week @ 2024-11-02 27645/week @ 2024-11-09 35971/week @ 2024-11-16

87,130 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
~72K SLoC