qmetrics.net

Memray

Python memory profiler with native code allocation tracing

Memray screenshot

Memray records memory allocations in Python code, extension modules, and the interpreter, then produces reports such as flame graphs from CLI or library use.

Overview

Memray is a memory profiler for Python that traces allocations in application code, native C/C++ extensions, and the interpreter itself. Unlike sampling profilers, it records function calls so reports can show an accurate call stack, including native frames when native tracking is enabled.

Typical workflows start from the command line: memray run wraps a script, module, or application and writes a binary capture file that reporters turn into flame graphs, tables, or other views. Live mode offers a terminal interface to inspect allocation patterns while a program runs, with sorting by total memory, own memory, or allocation count and optional per-thread views.

Native mode adds C/C++ library allocations to the same traces, which helps when extensions such as NumPy or pandas allocate heavily outside Python. Memray works with Python threads and native threads, integrates with pytest through pytest-memray for per-test summaries and memory limits, and can also be enabled programmatically via its API.

Installation targets Python 3.9+ on Linux and macOS only; other platforms are unsupported. Profiling adds limited overhead, with native tracking somewhat slower and toggled on demand.

Key features

  • Full call-stack allocation tracing
  • Native C/C++ allocation tracking
  • Flame graph and other reporters
  • Live terminal profiling mode
  • pytest plugin with memory limits
  • Python and native thread support
  • CLI and programmatic API
  • Low overhead relative to sampling tools

Use cases

  • Diagnosing high memory usage in Python apps
  • Finding memory leaks
  • Profiling extension-heavy scientific stacks
  • Preventing memory regressions in tests
  • Optimizing allocation hotspots

Tags

Similar software

arthas

Live Java application diagnostic shell

Arthas attaches to running JVM processes so developers can inspect classes, trace methods, and watch traffic without restarting apps or redeploying code. It supports interactive CLI, telnet, websocket, and browser console access.

★ 37.6k⟳ 4 days agoApache-2.0

py-spy

Low-overhead sampling profiler for live Python programs

py-spy attaches to a running CPython process or launches one, sampling stacks without code changes and reporting via top, dump, or recorded flame graphs.

★ 15.7k⟳ 8 days agoMIT

strace

Linux userspace syscall tracing utility

strace is a diagnostic and debugging utility for Linux with a command-line interface. It watches how processes interact with the kernel.

★ 2.7k⟳ 2 days agoLGPL-2.1

PromQL Parser

Rust lexer and parser for Prometheus PromQL queries

PromQL Parser is a Rust crate that lexes and parses PromQL expressions aligned with Prometheus query syntax. It targets embedders building tooling around Prometheus metrics queries.

★ 105⟳ 1 month agoApache-2.0

REA

MCP and CLI reverse-engineering toolkit for agents

REA connects coding agents and terminals to local analysis tools for binaries, Electron apps, websites, .NET, and Android targets. Setup registers MCP access and investigation skills via npm.

★ 480.8k⟳ todayMIT

Graphify

Codebase knowledge graph skill for AI coding assistants

Graphify maps a project’s code, docs, and media into a queryable local knowledge graph and installs as a skill for assistants such as Cursor and Claude Code.

★ 154.2k⟳ yesterdayApache-2.0