tracemallocqt: GUI to analyze Python tracemalloc snapshots

Nick Coghlan ncoghlan at redhat.com
Fri Mar 14 07:46:56 UTC 2014


Hey folks,

One of the new features coming in Python 3.4 is Victor Stinner's changes
to allow runtime configurable memory allocators, and the associated
"tracemalloc" module to record details of memory allocations within the
CPython runtime and extensions modules.

Victor is looking for feedback on the GUI he's creating to explore those
snapshots, so I figured I would pass his request along here.

Cheers,
Nick.

P.S. I also tracked down the BZ for the PySide vs Python 3 issue Victor
mentions below: https://bugzilla.redhat.com/show_bug.cgi?id=1045780

---------- Forwarded message ----------
From: Victor Stinner <victor.stinner at gmail.com>
Date: 14 March 2014 09:54
Subject: [Python-Dev] tracemallocqt: GUI to analyze tracemalloc snapshots
To: Python Dev <Python-Dev at python.org>


Hi,

To prepare my conference on tracemalloc for Pycon Montréal next month,
I wrote a GUI to analyze tracemalloc snapshots: "tracemallocqt".
https://bitbucket.org/haypo/tracemallocqt

It looks like that:

   http://www.haypocalc.com/tmp/tracemallocqt_python34.png

I'm looking for testers and feedback on the GUI. You may be curious to
see which parts of Python is allocating the most memory, or maybe test
your favorite application to check if it leaks memory or how its
memory footprint can be reduced.

To run tracemallocqt, you have to install PySide and get tracemalloc
snapshots. It looks like most Linux distributions provide PySide
packages.

To take snapshots, see tracemalloc documentation:
http://docs.python.org/dev/library/tracemalloc.html

In short, use Python 3.4 with "-X tracemalloc=25" command line option
and then call:
---
import pickle, tracemalloc
snap = tracemalloc.take_snapshot()
with open("dump.pickle", "wb") as fp: pickle.dump(snap, fp, 2)
snap = None
---

It's more fun with at least 2 snapshots to compare them ;-)

I force pickle version 2 because tracemallocqt currently only works on
Python 2. (Mostly because I don't see how to get PySide for Python 3
on Fedora 20.)

Not all applications work on Python 3.4 right now, you can use the
pytracemalloc project which is tracemalloc for Python 2.5-3.3. Sorry,
you have to patch Python and recompile it. Here are instructions to
install a patched Python 2.7 with tracemalloc:
http://pytracemalloc.readthedocs.org/#manual-installation

If you don't want to take snapshot, you can compare these two files:

   http://www.haypocalc.com/tmp/python34_start.pickle
   http://www.haypocalc.com/tmp/python34_after_import.pickle

The source browser will not find Python source code, because the
snapshots contain absolute paths.

Victor
_______________________________________________
Python-Dev mailing list
Python-Dev at python.org
https://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
https://mail.python.org/mailman/options/python-dev/ncoghlan%40gmail.com


-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia




More information about the python-devel mailing list