Memray is a memory profiler for Python, built and open sourced by Bloomberg. A memory profiler watches a running program and records every time it asks the computer for memory, then helps you see where the memory went. The point is to answer questions like why is my program using so much RAM, or where is it leaking memory over time. Memray tracks allocations made from Python code, from native extension modules written in C or C++, and from the Python interpreter itself. It traces every function call rather than sampling at intervals, so the call stack in its reports reflects what actually happened. It also follows native calls into C and C++ libraries, so the full path of a memory allocation through both languages is visible. The README says the slowdown from profiling is small in pure Python mode and larger when tracking native code, and that this can be turned on or off on demand. It handles Python threads and threads created from native code. The tool runs only on Linux and macOS; it does not install on Windows. It needs Python 3.7 or newer and is installed from PyPI with pip install memray. The project ships binary wheels for common platforms, with build-from-source instructions covering libdebuginfod, libunwind, and lz4 dependencies. The main way to use it is the memray command line. You run your script under memray run, which writes a binary recording, and then you generate reports from that recording: an HTML flame graph, an HTML table, a tree view, a textual summary, or live monitoring.
Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.