[silva-dev] possible memory leak with the EditorSupportNested

Clemens Robbenhaar robbenhaar at espresto.com
Tue Jul 29 18:52:59 CEST 2003


Hi,

 I have just finished a somewhat longer debugging session tracking down
something which looks like a memory leak in the "replace_text" and
"replace_heading" methods of the EditorSupportNested. (I like that
things like these make trouble a few days before my deadline ...)

 As I do not really understand what is going on I would like to ask
other people if they can reproduce the problem.
 
 Symptoms of the problems are the following:

 1. go to the edit tab of a Silva Document
 2. open some paragraph for editing
 3. click the "save" button

repeating step 3. for a while leads to an increase of reference counts 
of some ParsedXML documents ,HTTPRequests, etc in the 
/ControlPanel/DebugInfo/manage_main


If seems the problem goes away after the following two changes:

In the create_dom_forgiving change the 

            try:
                dom = ParsedXML(doc, '<p>%s</p>' % st)
                return dom
            except ExpatError, message:
to 
            try:
                dom = ParsedXML('_no_id', '<p>%s</p>' % st)
                return dom
            except ExpatError, message:

This seems to make some sense to me, as the first argument to the
ParsedXML constructor should be the id of the XML document,
and setting a DocumentElement instead of a string here is maybe not the
best idea. It could be I misunderstood something, however.

 After this change it seems the reference count increase of the 
HTTPRequest objects goes away, but some ParsedXML object reference
counts still grow.

 I have been able to fix the latter by appending a line to the
replace_text and replace_heading methods; after the last lines of these
methods:

        for child in newdom.childNodes:
            self._replace_helper(doc, node, child)

I have inserted something like:

        del  newdom._persistentDoc

... I do not understand what this really does, but this seems to stop
the remaining reference count increases. 


 Now I am really wondering if I have screwed up something in my local
customized version (it is actually a derivative of Silva 0.9.1.2, still,
using ParsedXML1.3.1 and Zope2.6.1), or if this is something which is
reproducible in other versions of Silva.
 
 It would be very kind if someone could enlighten me what the purpose of
the '_persistentDoc' attribute is and why this could cause a memory leak.


 Sorry for sending a somewhat confused mail to the list, but I am
currenty a bit confused myself ...


Cheers anyway,
Clemens

 



More information about the silva-dev mailing list