knadh/xmlutils.py — pull request #3 by obtuse (2013-04-15 16:16:53+00:00)
Title: Memory leak during iterparse

Every element created by iterparse must be explicitly deleted using `elem.clear()` to free up the allocated memory.

I've confirmed this makes a significant improvement while using a 17 GB input file :)

More info: http://eli.thegreenplace.net/2012/03/15/processing-xml-in-python-with-elementtree/#xml-stream-parsing-with-iterparse