Hi guys.
I’m trying to debug the sorcar addon and when using the custom object node I’ve noticed that if you use any node behind it and change values the memory grows without limit.
How do I know what in particular is making the memory go up?
Is it possible clear the BLI_Mempool Chunk memory from python?
The CustomObject node constantly duplicates the original object and then applies the rest of the node tree to the new copy.
I think it is the bpy.ops.object.duplicate() itself that increases the memory without limit, as it is done multiple times. Even if you later delete the copies and orphan data if you run it multiple times it still seems to increase the memory.
I could know that I increased the BLI_Mempoll chunk because I executed blender with --debug-memory and after increasing the memory in the f3 search engine I put “Memory Statistics” and saw that the one that increased the most was the BLI_Mempoll chunk
I created this little code to test and effectively increase memory every time you run:
ob = bpy.context.active_object
def duplicate_test_memory(repeat):
for b in range(repeat):
bpy.ops.object.duplicate(linked=False, mode='TRANSLATION')
#
bpy.ops.object.select_all(action='SELECT')
ob.select_set(False)
bpy.ops.object.delete(use_global=False)
#
for mesh in bpy.data.meshes:
if mesh.users < 1:
bpy.data.meshes.remove(mesh)
repeat = 100
if ob:
for r in range(repeat):
duplicate_test_memory(repeat)
else:
bpy.ops.mesh.primitive_cube_add(size=2, enter_editmode=False, location=(0, 0, 0))
ob = bpy.context.active_object
for r in range(repeat):
duplicate_test_memory(repeat)
Although now with this test it seems to increase the memory of ReportMessage and Report… :S
The idea is only to make a backup of the original if there is not already a backup. Then we work on the original, without fear since that’s what the backup was made for. This way we avoid being constantly duplicating, it is only duplicated if there is no previous backup.
This was just an illusion. It’s not possible to do it this way because if you never delete the original object you can never start over from the beginning of the node tree but at least I think the reason for the increase in memory is the massive duplication and removal of objects throughout the working process.