I wrote a Python program that acts on a large input file to create a few million objects representing triangles. The algorithm is:
The requirement of OFF that I print out the complete list of vertices before I print out the triangles means that I have to hold the list of triangles in memory before I write the output to file. In the meanwhile I'm getting memory errors because of the sizes of the lists.
What is the best way to tell Python that I no longer need some of the data, and it can be freed?
According to Python Official Documentation, you can force the Garbage Collector to release unreferenced memory with gc.collect()
. Example:
import gc
gc.collect()