How can I explicitly free memory in Python?

前端 未结 10 2808
青春惊慌失措
青春惊慌失措 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:04

    Python is garbage-collected, so if you reduce the size of your list, it will reclaim memory. You can also use the "del" statement to get rid of a variable completely:

    biglist = [blah,blah,blah]
    #...
    del biglist
    

提交回复
热议问题