Blender becomes very slow with large amount of objects sharing mesh data In my script I am importing a large amount of objects (+2500) but sharing the mesh data from one single primitive. While this has taken care of importing speed, it completely slows blender down. However when I import as individual primitives blender is very responsive even with + 2500 objects.

Why does blender slow down (frame rate, buttons, etc) when sharing mesh data blocks and is there anyway to aliviate this?

Code:

def create_mesh(name, radius, locat):
    #print (fList)

    # Create mesh and object
    mesh = bpy.data.meshes.new('Sphere')
    mesh = bpy.data.meshes['Primary']
    obj = bpy.data.objects.new('Shpere', mesh)
    #obj.show_name = True
    obj.scale = (radius, radius, radius)
    obj.location = locat 

    # Link object to scene and make active
    scn = bpy.context.scene
    scn.objects.link(obj)
    #scn.objects.active = obj
    #obj.select = True


    # Update mesh with new data
    mesh.update() 

    return obj
You're sharing one object data (Primary) among +2500 objects, but with this line:

bpy.data.meshes.new('Sphere')


... you're also creating +2500 orphan mesh data. It's easy to add several MBs to Blender's memory usage (verifiable through System Monitor), just running that bit of code:

import bpy

for i in range(1, 2500):
    bpy.data.meshes.new('Sphere')


The orphaned obdatas won't be reclaimed until loading new scene or quitting (to see them, select a mesh object, click the dropdown button to the left of the obdata's name in Properties area's Object Data tab). For scenes large enough, in systems with low RAM, this could slow down the whole system.