[Zope-dev] memory leak

Karl Anderson karl@digicool.com
11 Apr 2001 12:50:29 -0700


Dyon Balding <dyon@devcoder.com.au> writes:

> On Tue, Apr 10, 2001 at 05:27:28PM +0200, Marco Nova wrote:
> > Hello guys,
> > 
> > It seems that I've some memory leak problems and I want to understand where
> > I've to look for.
> > 
> > Scenario:
> > 
> > I've an IIS web server that generates an XML page (taking data from
> > SqlServer);
> > The Zope web server must retrieve the XML page, manage the data and render
> > them in HTML (I cant only apply a XSL stylesheet to XML).
> > 
> > The Facts:
> > 
> > I've written a external method that - using httplib - reads the XML page and
> > return a string that is the raw XML sources, than I've written another
> > external method that use ExpatBuilder of Products.ParsedXML.DOM to parse the
> > XML an generate a list of [(id - {mapping})] which will be accessed with a
> > dtml-in tag, so in the sequence-key I've access to the ID and with
> > sequence-item I can access to the mapping object.

Are you parsing the XML and creating this list from the DOM objects,
and then throwing them away?  Or are you parsing the XML and creating
this list from your pyexpat interface code, and never accessing the
DOM objects?

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.

-- 
Karl Anderson                          karl@digicool.com