memray

Profile Python memory allocations and generate temporal flamegraph HTML reports.

383|92|Updated Apr 30, 2022
One-click install
npx skills add https://github.com/scverse/spatialdata --skill memray
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: memray
Source: https://github.com/scverse/spatialdata/tree/main/.claude/skills/memray
Command: npx skills add https://github.com/scverse/spatialdata --skill memray

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

It helps you pinpoint where and when a Python program allocates memory so you can diagnose leaks, spikes, or inefficient allocation patterns instead of guessing.

Core Features & Use Cases

  • Profile memory over time: Use temporal flamegraphs to understand allocation behavior across the run, not just peak usage.
  • Generate a browser-friendly report: Produce an interactive HTML flamegraph from a recorded allocation trace.
  • Practical debugging workflow: Compare reports between runs to validate whether changes reduced churn or leaks.

Use Case: You run a data processing script in spatial omics and suspect memory growth during specific steps; this skill profiles allocations and visualizes where the memory pressure originates.

Quick Start

Profile your script by running it with the memray-run step (for example: pixi run -e profiling memray-run your_script.py).

Frequently Asked Questions about memray

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I diagnose a memory leak in a Python data pipeline?

A temporal flamegraph visualizes memory allocation behavior across the entire runtime of a Python program, helping you understand memory growth and allocation spikes over time rather than just showing peak usage.

How do I profile Python memory allocations on macOS and Linux?

To profile Python memory allocations on macOS and Linux, run your script using the memray-run command in the pixi profiling environment to record an output trace file.

Can I generate a browser-friendly report from a Python allocation trace?

Yes, you can generate a browser-friendly report by converting a recorded .bin trace file into an interactive HTML flamegraph using the memray-flame tool, which opens directly in your browser.

What is a temporal flamegraph and how does it help debug memory churn?

A temporal flamegraph visualizes memory allocation behavior across the entire runtime of a Python program, helping you understand memory growth and allocation spikes over time rather than just showing peak usage.

Does this memory profiling approach work for spatial omics batch scripts?

Yes, this memory profiling approach works for spatial omics batch scripts by tracking allocation behavior during specific data processing steps to identify where memory pressure originates.

How do I validate if changes reduced memory churn in a Python script?

You can validate if changes reduced memory churn by comparing temporal flamegraph reports between different runs of your Python script to observe the differences in allocation patterns.