[Zope-dev] memory leak
Marco Nova
nova@tera-it.com
Thu, 12 Apr 2001 12:03:01 +0200
> In either case, it seems like you shouldn't be using ParsedXML's
> ExpatBuilder, which is an interface to PyExpat which is made to create
> ParsedXML's DOM objects. You should be using your own PyExpat
> interface to parse this information from your XML input, without the
> overhead of generating a DOM tree that you're just going to throw
> away. The interface is documented in the XML-SIG topic area on
> python.org, and our ExpatBuilder should be a good example on how to
> interface with our PyExpat installation - just don't build the DOM if
> you don't use it.
>
> Regardless of what you *should* be doing :), or if I'm misreading you,
> if you aren't keeping references to the DOM objects being created,
> then they should be reclaimed by the GC, and you do seem to have DOM
> objects lying around. I'd like to see your code, is it short enough
> to post? Or you can chuck it into the collector or ParsedXML tracker.
>
> For debugging purporses, I'd suggest simplifying by supplying an XML
> string directly, rather than from an external server.
I've replaced ParsedXML's ExpatBuilder with the pyXML package and I used the
sax parser without modifing the code (except for the import), this is the
refcounts results.
Class April 12, 2001 11:55 am April 12, 2001 12:00
xml.dom.NodeList.NodeList 2103 3678 +1575
xml.dom.Text.Text 1263 2208 +945
xml.dom.NamedNodeMap.NamedNodeMap 507 885 +378
xml.dom.Element.Element 499 871 +372
xml.dom.Attr.Attr 339 591 +252
xml.dom.DocumentType.DocumentType 7 10 +3
xml.dom.Document.Document 7 10 +3
xml.dom.Document.Document increments by 1 each time an xml is procesed (I
tried to add a del doc at the end but it's ineffective).
So the problem is not ParsedXML but Zope itself or my bad methods.
Regards,
- mn