Skip to content

Repository files navigation

tracemalloc

CI codecov

tracemalloc is a Rust re-implementation of Python's tracemalloc module.

This project aims to improve upon the standard library implementation in the following ways:

  • Lower overhead and better concurrency by moving allocation work into per-thread ring buffers, draining asynchronously, and using sharded aggregators so the hot path avoids locks and allocator recursion.
  • Tighter metadata via aggressive interning, prefix-compressed stack traces, and delta-encoded snapshots so repeated file/frame info doesn’t explode memory.
  • Broader visibility by optionally interposing on the native allocator, tagging allocations by domain/ thread/interpreter, and observing some extension-level allocations traditional tracemalloc misses.
  • Stronger tooling with streaming and mmap-backed snapshots, instantaneous diffs, open exports (pprof / Perfetto), and time-sliced queries for modern profiling workflows.
  • Robustness upgrades like reentrancy guards, lossy backoff when buffers fill, and careful shutdown handling to keep tracing safe even under stress.

Prior Art

This project is heavily inspired by the standard library implementation of tracemalloc, so do go check it out!

About

A rusty port of python's `tracemalloc` module

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages