我应该在哪里调用垃圾回收器?在函数被调用后调用它是否会清除被调用函数的内存?
此外,调用gc.collect()和特定地对一个变量执行del
有什么区别?
def a():
b()
# should I call gc.collect() here?
# is there any other way to release memory allocated in the called function here?
def b():
# big allocation like
foo = ['abc' for x in range(10**7)]
# should I call gc.collect() here?
# should I do a foo = None and x = None here?