Measure the heap size of values
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-04-06 20:09:27 +02:00
malloc_size_of chore: sync dependencies (monorepo) 2026-04-06 15:21:03 +02:00
malloc_size_of_derive chore: sync dependencies (monorepo) 2026-04-06 15:21:03 +02:00
.gitignore Add gitignore file 2024-12-05 16:48:51 +13:00
Cargo.toml chore: sync dependencies (monorepo) 2026-04-06 15:21:03 +02:00
LICENSE-APACHE Add root level license files 2024-12-05 16:37:33 +13:00
LICENSE-MIT Add root level license files 2024-12-05 16:37:33 +13:00
README.md chore: sync dependencies (monorepo) 2026-04-06 20:09:27 +02:00

MallocSizeOf

A an allocator-agnostic crate for measuring the runtime size of a value including the size of any heap allocations that are owned by that value.

This crate is used by both Servo and Firefox for memory usage calculation.

Features

  • It isn't bound to a particular heap allocator.
  • It provides traits for both "shallow" and "deep" measurement, which gives flexibility in the cases where the traits can't be used.
  • It allows for measuring blocks even when only an interior pointer can be obtained for heap allocations, e.g. HashSet and HashMap. (This relies on the heap allocator having suitable support, which jemalloc has.)
  • It allows handling of types like Rc and Arc by providing traits that are different to the ones for non-graph structures.