6 releases

0.3.3 Feb 20, 2024
0.3.2 Feb 9, 2024
0.3.1 Oct 17, 2023
0.3.0 Jun 5, 2023
0.1.0 Nov 4, 2022

#33 in Visualization

Download history 4546/week @ 2024-07-19 4156/week @ 2024-07-26 4541/week @ 2024-08-02 4666/week @ 2024-08-09 6847/week @ 2024-08-16 7878/week @ 2024-08-23 7760/week @ 2024-08-30 8427/week @ 2024-09-06 8392/week @ 2024-09-13 8216/week @ 2024-09-20 31669/week @ 2024-09-27 10500/week @ 2024-10-04 7297/week @ 2024-10-11 9203/week @ 2024-10-18 8918/week @ 2024-10-25 8477/week @ 2024-11-01

36,448 downloads per month
Used in 19 crates (13 directly)

MIT/Apache

120KB
2.5K SLoC

Allocative

Crate implements lightweight memory profiler which allows object traversal and size introspection.

An object implementing Allocative trait is introspectable, and this crate provides two utilities to work with such objects:

Allocative overhead

When allocative is used, binary size is slightly increased due to implementations of Allocative trait, but it has no runtime/memory overhead when it is not used.

How it is different from other call-stack malloc profilers like jemalloc heap profiler

Allocative is not a substitute for call stack malloc profiler, it provides a different view on memory usage.

Here are some differences between allocative and call-stack malloc profiler:

  • Allocative requires implementation of Allocative trait for each type which needs to be measured, and some setup in the program to enable it
  • Allocative flamegraph shows object by object tree, not by call stack
  • Allocative shows gaps in allocated memory, e.g. spare capacity of collections or too large padding in structs or enums
  • Allocative allows profiling non-malloc allocations (for example, allocations within bumpalo)
  • Allocative allows profiling of memory for subset of the process data (for example, measure the size of RPC response before serialization)

Dependencies

~0.2–8MB
~62K SLoC