我正在尝试从内存中删除一个巨大的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