Skip to content

Library and proc macro to analyze memory usage of data structures in rust.

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

facebookexperimental/allocative

Allocative: memory profiler for Rust

This crate implements a lightweight memory profiler which allows object traversal and memory size introspection.

Usage

Allocative trait (typically implemented with proc-macro) is introspectable: Allocative values can be traversed and their size and sizes of referenced objects can be collected.

This crate provides a few utilities to work with such objects, the main of such utilities is flame graph builder which produces flame graph (see the crate documentation) like this:

sample-flamegraph.png

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 of 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 is needed
  • 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 of non-malloc allocations (for example, allocations within bumpalo bumps)
  • Allocative allows profiling of memory for subset of the process data (for example, measure the size of RPC response before serialization)

Runtime 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 enabled but not used.

Source code

Note there are several copies of this project on GitHub due to how Meta monorepo is synchronized to GitHub. The main copy is facebookexperimental/allocative.

License

Allocative is both MIT and Apache License, Version 2.0 licensed, as found in the LICENSE-MIT and LICENSE-APACHE files.

About

Library and proc macro to analyze memory usage of data structures in rust.

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages