memray
A memory profiler for Python applications
Decision gist · record as of 2026-08-14
Yes, if you develop on Linux or macOS and need to profile memory usage in Python applications. Memray's full call-stack tracing and native code support make it more precise than sampling profilers for finding leaks and allocation hotspots. Install friction is moderate (C extension, platform-limited), but prebuilt wheels and active maintenance reduce friction. No security vulnerabilities reported. Not suitable for Windows development.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Memray only works on Linux and macOS; cannot be installed on Windows or other platforms.
- Requires Python 3.9 or later.
- Medium install friction due to C extension requiring compilation on some platforms.
License · maintenance · safety
Apache 2.0 (permissive) — Apache 2.0 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects without licensing concerns.
last release 2026-08-07 (7 days) · last repo commit 2026-08-12 · 15,188 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 16,122,500 downloads/mo, #1,160 on PyPI
Alternatives
Verify before relying
# Install
python3 -m pip install memray
# Profile a script
python3 -m memray run my_script.py
# Generate a flame graph
memray flamegraph memray-my_script.*.bin- Performance overhead when profiling native code compared to Python-only profiling
- Whether the live monitoring mode (memray live) requires specific network or environment setup
- Compatibility with async/await patterns and coroutine-based applications
What it is and what it does
Memray is a memory profiler that instruments Python applications to capture every memory allocation, including calls into native C/C++ libraries. Unlike sampling profilers, it traces the full call stack, making it possible to pinpoint exactly where memory is being allocated and consumed. It works as both a command-line tool and a library, supporting Python threads and native threads in extensions.
The profiler generates multiple report formats—flame graphs, HTML tables, terminal trees, and summaries—to help developers analyze memory usage patterns, find leaks, and identify allocation hotspots. It's designed for production-like profiling with minimal overhead on Python code, though native code tracking incurs additional cost and can be toggled on demand.
Use it for
- Identify the root cause of high memory consumption in a long-running Python application
- Detect memory leaks by comparing allocation patterns before and after suspected leak code
- Find hotspots in code that cause excessive allocations and optimize them
- Profile applications that use C/C++ extensions to understand memory behavior across language boundaries
- Analyze test suite memory usage with pytest-memray plugin to catch regressions
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you develop on Linux or macOS and need to profile memory usage in Python applications.
Memray's full call-stack tracing and native code support make it more precise than sampling profilers for finding leaks and allocation hotspots. Install friction is moderate (C extension, platform-limited), but prebuilt wheels and active maintenance reduce friction. No security vulnerabilities reported. Not suitable for Windows development.
Install
memray on PyPI
Before you install
Medium install friction due to C extension requiring compilation on some platforms. Active maintenance with recent releases (7 days since last update) and strong community engagement (15188 stars). Prebuilt wheels available for Linux x86/x64 and macOS; building from source requires libdebuginfod-dev, libunwind, and liblz4.
Memray only works on Linux and macOS; cannot be installed on Windows or other platforms. Requires Python 3.9 or later.
License in practice
Apache 2.0 permissive license allows commercial and private use with minimal restrictions, making it suitable for most projects without licensing concerns.
Quickstart
# Install
python3 -m pip install memray
# Profile a script
python3 -m memray run my_script.py
# Generate a flame graph
memray flamegraph memray-my_script.*.bin
Verify before relying
- Performance overhead when profiling native code compared to Python-only profiling
- Whether the live monitoring mode (memray live) requires specific network or environment setup
- Compatibility with async/await patterns and coroutine-based applications
Package facts
| License | Apache 2.0 permissive |
| Python support | Supports the current Python release >=3.9.0 |
| Install friction | Medium. Platform-specific wheel |
| Runtime dependencies | 3 packagesjinja2richtextual |
| Maintenance | Actively maintained 7 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 16,122,500 / month, #1,160 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Intended Audience :: DevelopersLicense :: OSI Approved :: Apache Software LicenseOperating System :: MacOSOperating System :: POSIX :: LinuxProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Programming Language :: Python :: 3.15Programming Language :: Python :: 3.9Programming Language :: Python :: Implementation :: CPythonTopic :: Software Development :: Debuggers |
Evidence: memray-1.20.0-cp310-cp310-macosx_10_14_x86_64.whl; memray-1.20.0-cp310-cp310-macosx_11_0_arm64.whl; memray-1.20.0-cp310-cp310-manylinux2014_i686.manylinux_2_17_i686.whl; memray-1.20.0-cp310-cp310-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; memray-1.20.0-cp310-cp310-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; memray-1.20.0-cp310-cp310-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl; memray-1.20.0-cp310-cp310-musllinux_1_2_x86_64.whl; memray-1.20.0-cp311-cp311-macosx_10_14_x86_64.whl; memray-1.20.0-cp311-cp311-macosx_11_0_arm64.whl; memray-1.20.0-cp311-cp311-manylinux2014_i686.manylinux_2_17_i686.whl; memray-1.20.0-cp311-cp311-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; memray-1.20.0-cp311-cp311-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; memray-1.20.0-cp311-cp311-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl; memray-1.20.0-cp311-cp311-musllinux_1_2_x86_64.whl; memray-1.20.0-cp312-cp312-macosx_10_14_x86_64.whl; memray-1.20.0-cp312-cp312-macosx_11_0_arm64.whl; memray-1.20.0-cp312-cp312-manylinux2014_i686.manylinux_2_17_i686.whl; memray-1.20.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.whl; memray-1.20.0-cp312-cp312-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl; memray-1.20.0-cp312-cp312-manylinux_2_26_x86_64.manylinux_2_28_x86_64.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “flame graph generator”
- memrayMemray is a memory profiler for Python that traces every function…
- djdt-flamegraphIntegrates flame graph visualization into Django Debug Toolbar to…
- py-spypy-spy is a sampling profiler that attaches to running Python…
Give your agent the search over MCP, or paste the wish link into any chat.
More Debuggers packages
Extracts and displays stack frame and traceback data with context-aware source code rendering, used to power enhanced tracebacks in IPython and similar tools.
Install it if you need to display or inspect stack frames with source context; skip it if your use case doesn't involve frame introspection.
debugpy is a Debug Adapter Protocol implementation for Python that enables remote debugging of Python scripts and modules through standard DAP clients, with support for breakpoints, exception handling, and subprocess debugging.
Install it if you need remote debugging, DAP client integration, or programmatic control over breakpoints and exception handling.
Pylint is a static code analyzer that checks Python code for errors, enforces coding standards, detects code smells, and suggests refactoring improvements without executing the code.
Install it if you need thorough code analysis with inference-based bug detection; if speed is critical, consider pairing it with faster linters like ruff for…
yamllint checks YAML files for syntax errors, style violations, and structural problems like key repetition, line length, trailing spaces, and indentation issues.
ipdb is an IPython-enabled debugger that replaces Python's standard pdb with tab completion, syntax highlighting, and better introspection while maintaining the same pdb interface.
pyelftools parses and analyzes ELF binary files and DWARF debugging information in pure Python, with no external dependencies.
Install it if you need to read or analyze ELF binaries or debug information from Python.
See also pytest-memray · Pympler · py-spy · pystack · viztracer · pyinstrument · scalene · pyroscope-io · austin-dist · line-profiler