process

Memray – memory profiler for Python applications

Memray is a memory profiler for Python applications. It helps developers investigate growing memory usage and identify allocation behaviour that is difficult to explain from an application’s own logs.

The tool records allocation activity during execution and produces reports that connect memory costs to individual call stacks. This is particularly helpful when a Python program delegates substantial work to libraries outside pure Python.

Memray can be driven from the terminal or embedded in a program, so it fits both one-off investigations and targeted profiling of a particular operation.

This is free and open source software.

Key Features

  • Trace allocations made by Python code, the interpreter itself and native C or C++ extension modules.
  • Capture full call-stack information rather than relying solely on periodic sampling of memory usage.
  • Follow multi-threaded workloads, including threads created by native extension libraries.
  • Generate HTML flame graphs to explore which call paths account for peak allocated memory.
  • Produce HTML tables alongside terminal-based summary, statistics and allocation-tree reports.
  • Inspect allocations as a program runs with an interactive live terminal view, including sorting by memory or allocation count and switching between threads.
  • Enable native stack tracking when investigating applications that combine Python with compiled libraries.
  • Profile a script or module from the command line, or instrument selected code regions using Memray’s Tracker API.
  • Save binary capture data for subsequent analysis with different report generators, without repeating the original execution.
  • Use an optional companion pytest integration to report memory allocation in tests and enforce specified memory limits.

Website: github.com/bloomberg/memray
Support:
Developer: Bloomberg
License: Apache License 2.0

Memray options

Memray is written in Python. Learn Python with our recommended free books and free tutorials.


Best Free and Open Source Software Explore our carefully curated directory of recommended free and open source software, covering every major software category.

The directory forms part of our extensive collection of articles for Linux enthusiasts. It includes hundreds of detailed reviews, together with free and open source alternatives to proprietary software from companies such as Google, Microsoft, Apple, Adobe, IBM, Cisco, Oracle, and Autodesk.

LinuxLinks also covers interesting projects worth exploring, Linux-compatible hardware, free programming books and tutorials, and much more.

Know a useful free and open source Linux application that we haven’t covered? Tell us about it using our submission form.
Subscribe

Please read our Comment Policy before commenting.

Notify of
guest
0 Comments
Oldest
Newest Most Voted