Force garbage collection?

When you delete an object in blender, the data is left behind. As a result certain features (such as importing a mesh) act as if they are still in the scene. Is there a way to force garbage collection to get rid of this unused data?

Wondering about this myself, this problem has been in Blender for a long time.

Happens with textures too. It gets worse if you import assets from another blendfile that has been packed.

The workaround I’ve been using:

  • Open the blendfile
  • Unpack blendfile (if the Blenderfile has packed data)
  • Save blendfile under a different name
  • Close Blender
  • Repeat steps 1, 3, 4 until the file size of you blender file is no longer decreasing.
  • Last step: use the compression for you blender file to reduce file size even further.

I’m sure that can be automated through script ^

There is the “purge all” operator. It saves and reloads itself, purging all leftover, unused garbage. you can find it in the outliner, under the “orphaned objects” mode

Thanks for pointing that out. Purge All is exactly what I’m looking for. However, it seems it wont run so easily as a script due to it being picky about context…