从内存中删除lxml对象?

时间:2016-09-27 16:58:22

标签: python-2.7 lxml

我正在尝试从内存中删除一个巨大的lxml对象。 我试过close()方法但是tree.close()给我一个错误信息(它说树对象没有这个方法)。有人知道一个好技术吗?

    from lxml import etree as ET
    import gc
    path  = # insert a big xml path and filename here
    tree = ET.parse(path)
    # --- Here I use data in some way ---
    # now I don't use that tree anymore
    del tree
    gc.collect()
    # after this, data still in memory

0 个答案:

没有答案