I am writing a Blender 4.0+ add-on for exporting orthographic images of multiple objects in a blender file / multiple models in a folder: https://github.com/Jussumdev/OrthoBatch/releases
However I am running into issues with memory when rendering many images at once. When rendering and saving out ~100 2048×2048 images in a loop (total 500MB), Blender’s consumed memory easily passes 50GB and forces Blender to close.
I am using bpy.ops.render to render the stills, like this:
bpy.ops.render.render(animation=False, write_still = True)
bpy.ops.outliner.orphans_purge(do_local_ids=True, do_linked_ids=True, do_recursive=True)
(__init__.py line 439)
I am not sure what’s consuming all this memory- whether it is garbage created in the rendering process itself, or if I am creating garbage in one of the surrounding functions.
Any ideas? Alternatively, what are the best tools for memory profiling a Blender add-on?