help with xml.dom.minidom memory leak

Martin von Loewis loewis at
Thu May 24 17:32:24 CEST 2001

victor at (Victor Muslin) writes:

> Below is a short program that leaks memory. Any ideas how to plug the
> leak? What am I doing wrong?

What python version? With your exact code, I get a traceback

  File "/usr/local/lib/python1.5/site-packages/xml/dom/", line 441, in unlink
    for attr in self._attrs.values():

since, after unlinking the document, unlinking the DOM fails.

With Python 2.1 and PyXML 0.6.5, on Solaris 8, I cannot reproduce the
memory leak, nor can I reproduce it with plain Python 2.1 (i.e. no

In Python 2.0, there was a bug where pyexpat objects where not
properly deallocated after parsing, and would not be found by the
garbage collector either.

I recommend either installing PyXML, or updating to Python 2.1.


More information about the Python-list mailing list