Memray is a memory profiler for Python that traces memory allocations across Python code, native extension modules, and the Python interpreter itself.
Memray addresses memory analysis by instrumenting every function call to build an accurate call stack, rather than relying on sampling. This approach captures allocations in both Python and native C/C++ code, providing a complete picture of where memory is being used. The tool generates multiple report formats including flame graphs to visualize memory usage patterns. It operates as both a command-line tool and a library, allowing developers to integrate profiling into their workflows at different levels of granularity.
Memray suits teams working on performance-critical Python applications or those debugging memory leaks in codebases that mix Python with native extensions. It is particularly valuable when sampling profilers miss important allocation patterns or when native code contributions to memory usage need investigation. The tool works with Python threads and native threads spawned from C extensions. However, adoption requires a Linux or macOS environment, as the tool does not support other platforms.
The project maintains active engagement with its user community through a dedicated discussion space for success stories. Development shows responsiveness to user feedback and a commitment to improving the tool based on real-world usage patterns. The codebase includes comprehensive binary dependencies and build infrastructure to support installation across different system configurations.