Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory leakage in SAX with exception #36960

Closed
pandreetto mannequin opened this issue Jul 31, 2002 · 7 comments
Closed

Memory leakage in SAX with exception #36960

pandreetto mannequin opened this issue Jul 31, 2002 · 7 comments
Assignees

Comments

@pandreetto
Copy link
Mannequin

pandreetto mannequin commented Jul 31, 2002

BPO 589149
Nosy @loewis, @facundobatista

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = 'https://github.com/loewis'
closed_at = <Date 2004-11-09.00:25:03.000>
created_at = <Date 2002-07-31.15:02:10.000>
labels = ['expert-XML']
title = 'Memory leakage in SAX with exception'
updated_at = <Date 2004-11-09.00:25:03.000>
user = 'https://bugs.python.org/pandreetto'

bugs.python.org fields:

activity = <Date 2004-11-09.00:25:03.000>
actor = 'facundobatista'
assignee = 'loewis'
closed = True
closed_date = None
closer = None
components = ['XML']
creation = <Date 2002-07-31.15:02:10.000>
creator = 'pandreetto'
dependencies = []
files = []
hgrepos = []
issue_num = 589149
keywords = []
message_count = 7.0
messages = ['11765', '11766', '11767', '11768', '11769', '11770', '11771']
nosy_count = 4.0
nosy_names = ['loewis', 'nnorwitz', 'facundobatista', 'pandreetto']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = None
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue589149'
versions = []

@pandreetto
Copy link
Mannequin Author

pandreetto mannequin commented Jul 31, 2002

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

@pandreetto pandreetto mannequin closed this as completed Jul 31, 2002
@pandreetto pandreetto mannequin assigned loewis Jul 31, 2002
@pandreetto pandreetto mannequin added the topic-XML label Jul 31, 2002
@pandreetto pandreetto mannequin closed this as completed Jul 31, 2002
@pandreetto pandreetto mannequin assigned loewis Jul 31, 2002
@pandreetto pandreetto mannequin added the topic-XML label Jul 31, 2002
@loewis
Copy link
Mannequin

loewis mannequin commented Aug 5, 2002

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).

@pandreetto
Copy link
Mannequin Author

pandreetto mannequin commented Aug 5, 2002

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

@loewis
Copy link
Mannequin

loewis mannequin commented Sep 22, 2002

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?

@nnorwitz
Copy link
Mannequin

nnorwitz mannequin commented Jan 8, 2003

Logged In: YES
user_id=33168

Paolo, can you confirm that this bug should be closed?

@pandreetto
Copy link
Mannequin Author

pandreetto mannequin commented Jan 8, 2003

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.

@facundobatista
Copy link
Member

Logged In: YES
user_id=752496

Fixed in 2.3, as the submitter posted.

. Facundo

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant