After spamming you here many times with the proper way to purge data I've read the source file for purging orphan data and it seems they reload modules to purge orphan data. Now loading and reloading the module will make Blender lose all the current context and a lot of programmatic functionalities will go really crazy. Basically, any use for
bpy.context.~ will fail directly. I figured it out in a very unsuccessful method but did not work of course:
CC = bpy.context.blend_data.scenes['Scene'].copy() bpy.ops.wm.save_mainfile(filepath=bpy.data.filepath) bpy.ops.wm.open_mainfile(filepath=bpy.data.filepath) bpy.data.scenes['Scene'] = CC
I tried many scenarios to copy the contexts (different data and objects) and after reloading the module I paste it to the data. In this way, my module will continue with its rhythm or at least that's what I thought.
Do you have any ideas to save my codes and reload safely the modules?
I hope this will give you the idea of what I'm thinking of so far. I tried to delete all the unused meshes from users, materials .. etc nothing worked in my case and Blender will crush at the end.