Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Bugs

[issue14762] ElementTree memory leak

 

 

Python bugs RSS feed   Index | Next | Previous | View Threaded


report at bugs

May 9, 2012, 2:39 AM

Post #1 of 6 (46 views)
Permalink
[issue14762] ElementTree memory leak

New submission from Giuseppe Attardi <attardi [at] di>:

I confirm the presence of a serious memory leak in ElementTree, using the iterparse() function.
Memory grows disproportionately to dozens of GB when parsing a large XML file.

For further information, see discussion in:
http://www.gossamer-threads.com/lists/python/bugs/912164?do=post_view_threaded#912164
but notice that the comments attributing the problem to the OS are quite off the mark.

To replicate the problem, try this on a Wikipedia dump:

iterparse = ElementTree.iterparse(file)
id = None
for event, elem in iterparse:
if elem.tag.endswith("title"):
title = elem.text
elif elem.tag.endswith("id") and not id:
id = elem.text
elif elem.tag.endswith("text"):
print id, title, elem.text[:20]

----------
messages: 160266
nosy: Giuseppe.Attardi
priority: normal
severity: normal
status: open
title: ElementTree memory leak
type: resource usage
versions: Python 2.7

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2012, 4:18 AM

Post #2 of 6 (51 views)
Permalink
[issue14762] ElementTree memory leak [In reply to]

Changes by Antoine Pitrou <pitrou [at] free>:


----------
nosy: +eli.bendersky, flox

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2012, 4:39 AM

Post #3 of 6 (47 views)
Permalink
[issue14762] ElementTree memory leak [In reply to]

Eli Bendersky <eliben [at] gmail> added the comment:

Can you specify how you import ET? I.e. from the pure Python or the C accelerator?

Also, do you realize that the element iterparse returns should be discarded with 'clear'? [see tutorial here: http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python-with-elementtree/]

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2012, 5:47 AM

Post #4 of 6 (47 views)
Permalink
[issue14762] ElementTree memory leak [In reply to]

Jesús Cea Avión <jcea [at] jcea> added the comment:

Can this be reproduced in 3.2/3.3?

----------
nosy: +jcea

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2012, 6:35 AM

Post #5 of 6 (42 views)
Permalink
[issue14762] ElementTree memory leak [In reply to]

Giuseppe Attardi <attardi [at] di> added the comment:

You are right, I should discard the elements.

Thank you.

----------

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com


report at bugs

May 9, 2012, 6:36 AM

Post #6 of 6 (40 views)
Permalink
[issue14762] ElementTree memory leak [In reply to]

Changes by Giuseppe Attardi <attardi [at] di>:


----------
resolution: -> invalid
status: open -> closed

_______________________________________
Python tracker <report [at] bugs>
<http://bugs.python.org/issue14762>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/list-python-bugs%40lists.gossamer-threads.com

Python bugs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.