[Python-bugs-list] [ python-Bugs-589149 ] Memory leakage in SAX with exception
SourceForge.net
noreply@sourceforge.net
Wed, 08 Jan 2003 06:50:13 -0800
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: Martin v. Löwis (loewis)
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: 2003-01-08 15:50
Message:
Logged In: YES
user_id=551296
With Python 2.3a1 (#2, Jan 1 2003, 18:44:29) there's no
memory leakage.
With Python 2.2.2 (#1, Jan 3 2003, 12:42:27) the problem
still occurs.
I've used debian (unstable) package for both versions of python.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2003-01-08 02:07
Message:
Logged In: YES
user_id=33168
Paolo, can you confirm that this bug should be closed?
----------------------------------------------------------------------
Comment By: Martin v. Löwis (loewis)
Date: 2002-09-22 11:12
Message:
Logged In: YES
user_id=21627
There might indeed have been a memory leak in Python 2.1.3,
but I cannot reproduce this with Python 2.2 or CVS-Python
anymore. Can you please try a more recent version and see
whether the problem goes away?
----------------------------------------------------------------------
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