我應該在哪裏調用垃圾回收器?在函數被調用清除被調用函數的內存之後調用它嗎?打電話給gc.collect()
也就是調用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?
爲什麼要打電話給它? – Mark 2014-11-05 16:10:49
我想調用它,因爲我看到對於某些函數(b),我從另一個函數(a)調用,在我的heroku應用程序中,出現內存不足錯誤 – dowjones123 2014-11-05 16:12:14