How can I explicitly free memory in Python?

前端 未结 10 2557
青春惊慌失措
青春惊慌失措 2020-11-21 13:25

I wrote a Python program that acts on a large input file to create a few million objects representing triangles. The algorithm is:

  1. read an input file
10条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-21 14:25

    According to Python Official Documentation, you can force the Garbage Collector to release unreferenced memory with gc.collect(). Example:

    import gc
    gc.collect()
    

提交回复
热议问题