Last active
December 14, 2018 17:27
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import gc | |
from io import StringIO | |
import xml.etree.ElementTree as etree | |
import objgraph | |
def parse_xml(): | |
xml = """ | |
<LEVEL1> | |
</LEVEL1> | |
</ROOT> | |
""" | |
parser = etree.iterparse(StringIO(initial_value=xml)) | |
for _, elem in parser: | |
if elem.tag == 'LEVEL1': | |
break | |
def run(): | |
parse_xml() | |
gc.collect() | |
uncollected_elems = objgraph.by_type('Element') | |
print(uncollected_elems) | |
objgraph.show_backrefs(uncollected_elems, max_depth=15) | |
if __name__ == "__main__": | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment