garbage collection in python
<p>For the below code, I am not able to clear the memory allocated for 'root' variable evan after 'del root' and gc.collect(). I understand that in python, garbage collection releases automatically. Is there any way I can clear it more?</p>

<pre><code>from __future__ import with_statement
import os
import sys
from memory_profiler import profile
import gc
try:
    import xml.etree.cElementTree as ET
except ImportError:
    import xml.etree.ElementTree as ET



def f():
    with open('file.xml') as f:
        output_xml_str = f.read()
    root = ET.fromstring(output_xml_str)
    del root

@profile
def main():
    x = {}
    for i in xrange(10000):
        x[i] = i+1
    del x
    f()
    for i in range(12):
        gc.collect()

if __name__ == "__main__":
    sys.exit(main())
</code></pre>

<p>and here's profiling output</p>

<p><a href="https://i.stack.imgur.com/wNu4E.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wNu4E.png" alt="enter image description here"></a></p>