--- id: memray version: "1.20.0" license: Apache 2.0 license_treatment: permissive maintenance: active --- # memray — A memory profiler for Python applications License: permissive · Maintenance: active · Downloads: 16.1M/mo ## 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 above — verify before relying. Memray is a memory profiler for Python that traces every function call to track memory allocations across Python code, native extensions, and the interpreter itself, generating reports like flame graphs and tables to analyze memory usage. 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 pip install memray uv add memray poetry add memray ## Installing memray 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. 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 Memray only works on Linux and macOS; cannot be installed on Windows or other platforms. Requires Python 3.9 or later. 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_current - Install friction: medium - Maintenance: active - Downloads: 16.1M/month (top 5,000 on PyPI) - Known vulnerabilities: none known ## Tags python memory profiler, memory leak detection, allocation tracking, flame graph generator, native code profiling, memory usage analysis, call stack tracing, profiling, memory-analysis, debugging [View on SkillFed](https://skillfed.io/packages/memray) · [View on PyPI](https://pypi.org/project/memray/)