Python garbage collection

后端 未结 7 1966
深忆病人
深忆病人 2020-12-05 04:38

I have created some python code which creates an object in a loop, and in every iteration overwrites this object with a new one of the same type. This is done 10.000 times,

7条回答
  •  眼角桃花
    2020-12-05 04:48

    If you're creating circular references, your objects won't be deallocated immediately, but have to wait for a GC cycle to run.

    You could use the weakref module to address this problem, or explicitly del your objects after use.

提交回复
热议问题