# bloomberg/memray

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/bloomberg-memray).**

14,885 stars · 434 forks · Python · apache-2.0

## Links

- GitHub: https://github.com/bloomberg/memray
- Homepage: https://bloomberg.github.io/memray/
- awesome-repositories: https://awesome-repositories.com/repository/bloomberg-memray.md

## Topics

`hacktoberfest` `memory` `memory-leak` `memory-leak-detection` `memory-profiler` `profiler` `python` `python3`

## Description

Memray is a memory profiler for Python that tracks heap allocations in both Python code and native C or C++ extensions. It captures memory events by hooking into the language runtime and traversing call stacks, providing a comprehensive view of how an application consumes memory. The tool is designed to minimize performance impact on the target application by using thread-local buffering and streaming data to an external process or file.

The project distinguishes itself through its ability to monitor complex, multi-threaded systems and child processes in real-time. It provides diagnostic utilities that allow developers to attach to running processes, filter memory data by specific threads, and visualize allocation patterns through interactive flame graphs. These graphs support temporal inspection, enabling users to analyze memory usage across specific time intervals during execution.

Beyond live monitoring, the tool includes mechanisms for automated memory validation and regression testing. It can detect memory leaks by identifying objects that remain in memory at the end of a session and allows developers to enforce resource consumption thresholds within continuous integration pipelines. The profiler also generates detailed statistics and hierarchical call graphs, which help pinpoint inefficient allocation patterns such as frequent, short-lived object creation.

## Tags

### Development Tools & Productivity

- [Memory Profiling](https://awesome-repositories.com/f/development-tools-productivity/debugging-profiling-testing/debugging-diagnostics/performance-resource-profilers/memory-profiling.md) — Analyzes and optimizes heap allocation patterns in Python applications to identify memory leaks.
- [Memory Regression](https://awesome-repositories.com/f/development-tools-productivity/debugging-profiling-testing/test-execution-management/test-suites/memory-regression.md) — Integrates memory tracking into automated test runs to detect memory regressions or leaks. ([source](https://bloomberg.github.io/memray/tutorials/index.html))
- [Native Stack Unwinders](https://awesome-repositories.com/f/development-tools-productivity/dynamic-variable-evaluators/stack-frame-inspectors/native-stack-unwinders.md) — Traverses the call stack of both managed and native code frames to map memory events to specific source code locations.
- [Concurrent Memory Profilers](https://awesome-repositories.com/f/development-tools-productivity/thread-managers/concurrent-memory-profilers.md) — Tracks memory usage across both Python and native threads to provide a complete view of memory activity. ([source](https://bloomberg.github.io/memray/_sources/overview.rst.txt))

### System Administration & Monitoring

- [Memory Profilers](https://awesome-repositories.com/f/system-administration-monitoring/diagnostic-tools/diagnostics/memory-profilers.md) — Tracks and visualizes heap allocations in Python and native extensions to identify memory leaks.
- [Memory Profilers](https://awesome-repositories.com/f/system-administration-monitoring/memory-profilers.md) — Observing live memory allocation statistics in a terminal interface to understand the immediate impact of specific code operations on system resources.
- [Live Process Profilers](https://awesome-repositories.com/f/system-administration-monitoring/diagnostic-tools/diagnostics/memory-profilers/live-process-profilers.md) — Connects to an active application to monitor and record memory allocation patterns in real-time. ([source](https://bloomberg.github.io/memray/attach.html))
- [Memory Usage Analyzers](https://awesome-repositories.com/f/system-administration-monitoring/memory-usage-analyzers.md) — Fails automated tests that exceed defined memory thresholds and provides detailed breakdown of responsible functions. ([source](https://bloomberg.github.io/memray/index.html))
- [Flame Graph Generators](https://awesome-repositories.com/f/system-administration-monitoring/trace-visualization/flame-graph-generators.md) — Transforms raw memory allocation data into interactive flame graphs for analyzing peak memory usage.
- [Performance Analysis Tools](https://awesome-repositories.com/f/system-administration-monitoring/performance-analysis-tools.md) — Monitors resource consumption and identifies high-impact functions within complex software environments.
- [Real-Time Monitoring Dashboards](https://awesome-repositories.com/f/system-administration-monitoring/real-time-monitoring-dashboards.md) — Displays live memory usage statistics while code executes to help observe the immediate impact of operations. ([source](https://bloomberg.github.io/memray/run.html))
- [Remote Profiling Interfaces](https://awesome-repositories.com/f/system-administration-monitoring/monitoring-and-observability/execution-tracing-analysis/remote-profiling-interfaces.md) — Connects a monitoring interface to a running application process to observe memory behavior remotely. ([source](https://bloomberg.github.io/memray/live.html))
- [Stack Trace Hierarchy Visualizers](https://awesome-repositories.com/f/system-administration-monitoring/trace-visualization/stack-trace-hierarchy-visualizers.md) — Displays interactive tree representations of memory allocations at peak usage to identify high-memory source locations. ([source](https://bloomberg.github.io/memray/flamegraph.html))

### Testing & Quality Assurance

- [Flame Graph Visualizers](https://awesome-repositories.com/f/testing-quality-assurance/performance-testing-analysis/performance-diagnostics/execution-profilers/flame-graph-visualizers.md) — Generates interactive flame graphs from captured profiling data to provide a visual representation of memory consumption. ([source](https://bloomberg.github.io/memray/overview.html))
- [Memory Leak Detection](https://awesome-repositories.com/f/testing-quality-assurance/debugging-diagnostics/memory-leak-detection.md) — Identifies objects remaining in memory at the end of a session to detect potential memory leaks. ([source](https://bloomberg.github.io/memray/flamegraph.html))
- [Profiling Visualization Filters](https://awesome-repositories.com/f/testing-quality-assurance/profiling-visualization-filters.md) — Hides low-level implementation details or internal tool frames from visualization reports to reduce noise and focus on application-level code during performance analysis. ([source](https://bloomberg.github.io/memray/flamegraph.html))

### Operating Systems & Systems Programming

- [Memory Allocation Tracers](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/allocation-strategies/dynamic-memory-allocation/memory-allocation-tracers.md) — Hooks into low-level memory allocation functions to capture and record heap allocation events.
- [Child Process Memory Tracers](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/process-lifecycle-orchestrators/child-process-management-helpers/child-process-memory-tracers.md) — Automatically captures memory allocation data for child processes created via forks. ([source](https://bloomberg.github.io/memray/run.html))
- [Allocation Frequency Analyzers](https://awesome-repositories.com/f/operating-systems-systems-programming/kernel-core-internals/process-and-memory-management/memory-management/allocation-strategies/dynamic-memory-allocation/memory-allocation-tracers/allocation-frequency-analyzers.md) — Identifies short-lived or high-frequency object allocations to help pinpoint inefficient memory usage patterns. ([source](https://bloomberg.github.io/memray/temporary_allocations.html))

### Software Engineering & Architecture

- [Temporal Memory Profilers](https://awesome-repositories.com/f/software-engineering-architecture/memory-usage-analysis/temporal-memory-profilers.md) — Creates temporal flame graphs to visualize memory usage and allocation patterns across specific time intervals. ([source](https://bloomberg.github.io/memray/flamegraph.html))
- [Memory Usage Analysis](https://awesome-repositories.com/f/software-engineering-architecture/memory-usage-analysis.md) — Summarizes total allocations and memory distribution to help identify memory-intensive operations. ([source](https://bloomberg.github.io/memray/run.html))
- [Thread-Aware Memory Analyzers](https://awesome-repositories.com/f/software-engineering-architecture/memory-usage-analysis/thread-aware-memory-analyzers.md) — Filters memory allocation data by individual threads to isolate and investigate specific memory usage patterns. ([source](https://bloomberg.github.io/memray/flamegraph.html))
- [Symbol Resolution Engines](https://awesome-repositories.com/f/software-engineering-architecture/symbol-resolution-engines.md) — Translates raw memory addresses into human-readable function names and line numbers using debug information.

### Artificial Intelligence & ML

- [Performance Regression Analyzers](https://awesome-repositories.com/f/artificial-intelligence-ml/regression-analysis/performance-regression-analyzers.md) — Integrates memory usage checks into test suites to automatically detect and prevent performance regressions.

### Programming Languages & Runtimes

- [Concurrent Execution Monitors](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/concurrency-models/concurrency/execution-models/multi-threaded-execution/concurrent-execution-monitors.md) — Tracks and isolates memory allocation patterns across multiple threads and child processes.
- [Native Memory Lifecycle Management](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability/native-memory-lifecycle-management.md) — Captures memory allocation data from native extensions alongside Python code. ([source](https://bloomberg.github.io/memray/tutorials/index.html))
- [Native C Interoperability](https://awesome-repositories.com/f/programming-languages-runtimes/language-interoperability/native-c-interoperability.md) — Traces memory usage across both Python code and native C or C++ extensions.
