Hi,
Perhaps one of the Blender scripting experts might be able to help me with this.
The following code is causing a weird memory leak and I’m not sure why. The code creates a panel with a single checkbox in the ‘3D View’ tool shelf (the shelf to the right of the viewport). Whenever the checkbox in the panel is toggled Blender’s memory count increases alarmingly. Any idea why this is happening?
import bpy
class HelloWorldPanel(bpy.types.Panel):
"""Creates a Panel in the View3D UI panel"""
bl_label = "Mesh Stats"
bl_idname = "MESHSTATS_PT_hello"
bl_space_type = 'VIEW_3D'
bl_region_type = 'UI'
def draw(self, context):
layout = self.layout
row = layout.row()
my_settings = context.scene.my_settings
row.prop(my_settings["my_bool"], "value")
class SceneSettingItem(bpy.types.PropertyGroup):
name = bpy.props.StringProperty(name="Test Prop", default="Unknown")
value = bpy.props.BoolProperty(name="Test Prop", default=False)
def register():
bpy.utils.register_class(SceneSettingItem)
bpy.types.Scene.my_settings = bpy.props.CollectionProperty(type=SceneSettingItem)
my_item = bpy.context.scene.my_settings.add()
my_item.name = "my_bool"
my_item.value = False
bpy.utils.register_class(HelloWorldPanel)
def unregister():
bpy.utils.unregister_class(HelloWorldPanel)
if __name__ == "__main__":
register()