[Python-bugs-list] [ python-Bugs-589149 ] Memory leakage in SAX with exception

noreply@sourceforge.net noreply@sourceforge.net
Wed, 31 Jul 2002 08:02:10 -0700


Bugs item #589149, was opened at 2002-07-31 17:02
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=589149&group_id=5470

Category: XML
Group: Python 2.1.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Paolo Andreetto (pandreetto)
Assigned to: Nobody/Anonymous (nobody)
Summary: Memory leakage in SAX with exception

Initial Comment:
Trying the following test:

#!/usr/bin/python

import sys,string,StringIO,traceback,time,gc
import xml.sax,xml.sax.handler
gc.set_debug(gc.DEBUG_SAVEALL)

class SimpleHandler(xml.sax.handler.ContentHandler):
    def __init__(self):
        pass

    def startElement(self,name,attrs):
        print 'start ',name

    def endElement(self,name):
        print 'end ',name

    def characters(self,content):
        print content

class SimpleErrorHandler(xml.sax.handler.ErrorHandler):
    def __init__(self):
        pass
        
    def fatalError(self,e):
        print e

myHandler=SimpleHandler()
myErrHandler=SimpleErrorHandler()
data='<test>something</>'
while 1:
    gc.collect()
    print len(gc.garbage)
    
    try:
        #xml.sax.parseString(data,myHandler,myErrHandler)
        xml.sax.parseString(data,myHandler)
    except Exception, e:
        sinfo=sys.exc_info()
	traceback.print_tb(sinfo[2],None)
    time.sleep(1)

it seems that lots of object remain uncollectable.
Using the SimpleErrorHandler the behaviour of gc is
good but a memory leakage still remain (4Kb every 30
seconds).
Tests run on i386 with debian/Linux (sid), python 2.1.3
(Build of July 29th).

Thanks

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=589149&group_id=5470