How can I explicitly free memory in Python?

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

    The del statement might be of use, but IIRC it isn't guaranteed to free the memory. The docs are here ... and a why it isn't released is here.

    I have heard people on Linux and Unix-type systems forking a python process to do some work, getting results and then killing it.

    This article has notes on the Python garbage collector, but I think lack of memory control is the downside to managed memory

提交回复
热议问题