[Python-bugs-list] [ python-Bugs-589149 ] Memory leakage in SAX with exception
noreply@sourceforge.net
noreply@sourceforge.net
Mon, 05 Aug 2002 01:25:12 -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
----------------------------------------------------------------------
>Comment By: Paolo Andreetto (pandreetto)
Date: 2002-08-05 10:25
Message:
Logged In: YES
user_id=551296
This is correct, it's my fault, but removing the
gc.set_dubug instruction the situation doesn't change. The
script is just a simple test, my trouble comes from a memory
leakage into SOAPpy module which uses another SAX-based
XML-parser.
If you think the problem doesn't depends on the python core,
please close this bug.
Thanks
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-08-05 04:06
Message:
Logged In: YES
user_id=21627
Your analysis of this result is wrong. Instead, the result
shows that all objects *are* collectible, and that there is
merely cyclic garbage in case of a parser error - this
garbage *will* be collected, unless you explicitly ask the
GC to save it (which you do in your example).
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=589149&group_id=5470