objgraph

Drawing Python object reference graphs

About

objgraph is a module that lets you visually explore Python object graphs. I've used it in the past to go hunt for memory leaks in Python programs as described by this series of blog posts:

You'll need graphviz if you want to draw pretty graphs.

Examples

Try this in a Python shell:

>>> x = []
>>> y = [x, [x], dict(x=x)]
>>> import objgraph
>>> objgraph.show_refs([y])

You should see a graph like this:

[graph of objects reachable from y]

Now try

>>> objgraph.show_backrefs([x])

and you'll see

[graph of objects from which y is reachable]

Documentation

You'll have to rely on pydoc objgraph. Sorry.

Installation

easy_install objgraph or download it from PyPI

Development

The source code can be found in this Bazaar repository: https://code.launchpad.net/~mgedmin/objgraph/trunk.

To check it out, use bzr get lp:objgraph.

Report bugs at https://bugs.launchpad.net/objgraph.