💉 Attaching to running processes! More readable flame graphs! #272
godlygeek
announced in
Announcements
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi everyone!
Version 1.5.0 of Memray has just been released. The biggest new feature is a new subcommand,
memray attach
, which lets you start tracking new allocations some already running process makes.The basic usage is just
memray attach <pid>
, where<pid>
is the process ID you want to attach to. By default this will show a live TUI showing all allocations as they happen, but you can use-o somefile.bin
to ask the process to write allocations to a capture file instead, so that you can analyze them with any of our reporters. Note that this will only capture allocations performed after you attached. Memray can't show you where memory was allocated before the time when you attached to the process.The process you're attaching to must be a Python process running in an environment with the Memray package installed already, and you must be privileged to attach a debugger to that process. Also, you'll need to have either
gdb
orlldb
installed. You can read all the gory details in the docs.In addition to that major new feature, we have two quality of life improvements that make our flame graphs easier to interpret. First, we now consider frames inside of
importlib
to be "irrelevant", so they will be hidden by default unless you uncheck the "Hide Irrelevant Frames" checkbox. That changes our flame graphs from this:to this:
So beautiful! This should make it much easier to follow through imports in the flame graph without drowning in implementation details of how Python performs imports. Additionally, we now have a new checkbox, "Hide Import System Frames". In addition to hiding those
importlib
implementation details, this also results in theimport
calls themselves being hidden:Since most programs are structured to do all of their imports before starting to do any of the interesting work, this lets you more easily zero in on the places where interesting work is happening. That's especially useful because often when you make a minimal reproducer for some memory issue you're debugging, the imports of large libraries like
numpy
can take up a lot of room in the flame graph, making it hard to see the more relevant stuff that you're trying to analyze.Additionally, we've removed the warning that macOS support is experimental. At this point, we consider macOS to be fully supported! 🍎
As always, please try this new release out, and feel free to open an issue if you find any problems, or perhaps a discussion thread if you have any feedback or questions.
Happy debugging! 🐜
Beta Was this translation helpful? Give feedback.
All reactions