bloomberg

memray: Profile Python Memory Allocations

Memray is Bloomberg’s Python memory profiler for tracking allocations across Python code, native extensions, and the interpreter. It produces reports such as flame graphs and works on Linux and macOS, helping developers investigate high memory use, leaks, and allocation hotspots.

ActivePythonApache-2.0Developer ToolsCLIMemory Profiler
Stars
15.4k
Forks
481
Stars, last 30 days
+35
Last commit
3 days ago
Contributors
76

Our take

Activeregular commits and releases

Health score

57/100

How it is scored
Activity
57
Community
76
Issues
47
Pull requests
46

+35 stars in the last 30 days

  • Merges more pull requests than 76% of the projects we track
  • Slower to merge pull requests than 83% of the projects we track

Memray is a focused profiler with active development and broad contributor participation, suited to Python teams that need detailed allocation traces on supported platforms.

Good fit if

  • You need call-stack-based allocation profiling for Python code, including optional native C/C++ tracking.
  • Your development or production environment runs Linux or macOS and uses Python 3.9 or newer.
  • You want an actively maintained tool: the project reports regular commits and releases, with contributions from many contributors and no single-contributor concentration.

Look elsewhere if

  • You need a profiler that runs on Windows, which Memray does not support.
  • You need a sampling profiler rather than Memray’s call-tracing approach.
  • Your application cannot accommodate a profiler that includes a C extension or the system dependencies required to build from source.
All health signals
Last commit2026-10-27 (3 days ago)
Commits, last 90 days68
Releases, last 12 months3 (latest v1.20.0, 2026-08-07)
Contributors76 (top contributor: 39% of commits)
Issues closed, last 90 days10 (typically closed in 37 days)
Pull requests merged, last 90 days55 (typically merged in 3 days)
Project age4 years

Checked on 2026-10-31 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

15,420

Forks

490

Change since Nov 17, 2026: +2 stars·0 forks

Overview

Memray is a Python memory profiler from Bloomberg. It tracks allocations in Python code, native extension modules, and the Python interpreter, helping developers investigate high memory use, memory leaks, and allocation hotspots. It runs on Linux and macOS and can be used from the command line or as a library.

Unlike sampling profilers, Memray traces function calls to represent call stacks, including native C/C++ frames when native tracking is enabled. Captures can be examined through reports such as flame graphs, tables, terminal summaries, and a live interface.

Key Features

  • Trace allocation call stacks across Python and, optionally, native C/C++ code.
  • Record memory use while running a script, module, or application from the CLI.
  • Generate flame graphs, tables, tree views, summaries, and statistics from capture files.
  • Inspect allocations interactively in a terminal while a program runs.
  • Track allocations across Python threads and native threads.
  • Enable tracking programmatically with the memray.Tracker API.
  • Use the separate pytest-memray plugin to report or limit memory use in tests.

Use Cases

  • Python application developers can trace unexpectedly high memory use back to the functions and call paths responsible.
  • Teams using packages with C extensions can enable native tracking to investigate allocations beyond Python-level code.
  • Engineers diagnosing suspected leaks can capture a workload and inspect its allocation patterns in a report.
  • Developers working with long-running scripts can use live mode to inspect memory behavior before execution finishes.
  • Test authors can use pytest-memray to surface allocation totals or enforce per-test memory limits.

What you need

Detected in the repository

  • Node.js (from package.json)
  • Python >=3.9.0 (from pyproject.toml)
  • A Dockerfile, so it can run in a container
  • A test suite and automated checks on GitHub Actions

License in plain words

Apache-2.0permissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the license, the NOTICE file and a note of your changes
  • Share your changes: no
  • Includes an explicit patent grant from the contributors:

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install the latest release with pip:

python3 -m pip install memray

For example, profile a script and create a flame graph:

python3 -m memray run -o output.bin my_script.py
python3 -m memray flamegraph output.bin

See the README and documentation for native tracking, API usage, and build instructions.

Considerations

  • Memray only supports Linux and macOS. A binary wheel may not be available for every supported system, in which case source installation requires native dependencies such as liblz4 and, on Linux, libunwind and libdebuginfod.
  • Native tracking is optional and gives a more complete view of C/C++ allocations, but the README notes that it is slower than tracking without native code.
  • The project is actively maintained, with recent commits and releases, and its contributor base is not concentrated around one person. Reported issue closure and pull request merge times may still matter when evaluating support needs.
  • Memray is licensed under Apache-2.0. Review the license terms when distributing or incorporating it into a product.

Found this useful?

Share it with someone who would like memray.