I have to load lots of objects/meshes(50k) in Blender and render them for which I have written a Python script. My meshes have lots of vertices/faces (in the range of ~[10k, 70k]). I noticed that memory usage keeps increasing as despite removing them. Memory usage goes down a little after removing the object but it is still increased compared to the time before loading the object. For instance, when I load Blender memory usage is aroun 8MBs
but after loading/removing 10
objects memory usage is around 200MBs
(more or less). If I do not remove the 10
objects the memory usage is going to be around 300MBs
or so. I wonder, does anyone have a solution for how I can properly import and remove objects/meshes so that I can prevent memory leak?
Here's a simplified version of my rendering pipeline:
do while there are still unrendered objects
load an obj file
render the mesh
remove the mesh
end while
So far, I have done the followings to lessen memory foot print:
I use both Cycles and Blender internal renderer for different purposes. However, I do not know what to do in Cycles to reduce memory foot print. In Blender internal, I check the Free Image Textures:
And in User Preferences --> Edit I do the followings:
This is also how I remove the meshes/objects:
for obj in bpy.context.scene.objects:
if obj.type == 'MESH':
obj.select = True
else:
obj.select = False
bpy.ops.object.delete()
where you can check type
against any of the following values according to this documentation:
[‘MESH’, ‘CURVE’, ‘SURFACE’, ‘META’, ‘FONT’, ‘ARMATURE’, ‘LATTICE’, ‘EMPTY’, ‘CAMERA’, ‘LAMP’, ‘SPEAKER’]