How to delete multiple pandas (python) dataframes from memory to save RAM?

后端 未结 3 675
隐瞒了意图╮
隐瞒了意图╮ 2020-11-27 12:22

I have lot of dataframes created as part of preprocessing. Since I have limited 6GB ram, I want to delete all the unnecessary dataframes from RAM to avoid running out of mem

3条回答
  •  被撕碎了的回忆
    2020-11-27 13:13

    In python automatic garbage collection deallocates the variable (pandas DataFrame are also just another object in terms of python). There are different garbage collection strategies that can be tweaked (requires significant learning).

    You can manually trigger the garbage collection using

    import gc
    gc.collect()
    

    But frequent calls to garbage collection is discouraged as it is a costly operation and may affect performance.

    Reference

提交回复
热议问题