Out of memory after rendering thousands of similar scenes I have a project on which I have to render thousands of different screenshots of a scene. It is basically a for loop that changes the scene, calculates some stuff and renders.
However after around 2000 I blender complains that it is out of memory. In fact at each iteration it shows that the usage of memory is increasing, but I don't understand why, since I am not adding new elements to the scene and i am not keeping information from previous iterations.

I guess that there is some variable which is not being free in the loop. However I have no idea on how to find out that. Do someone have any ideas?
EDIT:
This is the error that I have:
In case anyone have a similar problem, I figured out the solution.
My script was generating a new texture at each iteration. I thought it was being discarded but actually not, blender was retaining this information as orphan data. So I simply needed to add bpy.ops.outliner.orphans_purge() at each iteration to clean this unused data that was loading my memory.