Python running out of memory parsing XML using cElementTree.iterparse
问题 A simplified version of my XML parsing function is here: import xml.etree.cElementTree as ET def analyze(xml): it = ET.iterparse(file(xml)) count = 0 for (ev, el) in it: count += 1 print('count: {0}'.format(count)) This causes Python to run out of memory, which doesn't make a whole lot of sense. The only thing I am actually storing is the count, an integer. Why is it doing this: See that sudden drop in memory and CPU usage at the end? That's Python crashing spectacularly. At least it gives me