Seb Bacon wrote:

So, say Foo is leaking because it is referenced from O which can't be collected. Given 100 things which refer to Foo, how do I identify which one is O? And of course, then O may be leaking because it is referenced from P...

I've been looking into memory leaks of my own, and put together a small module that outputs the information available from the gc.garbage list in a format that Graphviz ( can then render as an image (GIF, SVG, etc) that makes it a bit easier to see the cycles.

Here's a sample image:

Here's the code

It shouldn't be too hard to use that in your own code, something like:

  import visualize_pyobjects
  cycles = visualize_pyobjects.prune_stems(gc.garbage)
  visualize_pyobjects.create_dot(cycles, '/tmp/')

and then, run the graphviz 'dot' program from the command line to create a GIF file:

dot -Tgif </tmp/ >/tmp/foo.gif

(use a '-Tsvg' option to create an SVG file, which is smaller and easily viewed and edited with things like sodipodi I believe)


Zope-Dev maillist - [EMAIL PROTECTED]
** No cross posts or HTML encoding! **
(Related lists - )

Reply via email to