Remove image name/slot from File Output node Error: Not freed memory blocks: 1, total unfreed memory

Is this a bug or am i doing something wrong ?

Test:
Open Blender from the commandline.
Run script that will add a new File Output node, delete the original image name and add a new custom name; then close Blender and the command prompt will kick out “Error: Not freed memory blocks: 1, total unfreed memory”

If i add the File Output node, add a new image name (not touching the original) and then manual delete the original from the Properties panel, Blender closes with out any error.

Also tried newNode.file_slots.clear() and the same error occurs.

Using Blender 3.5

Heres a quick video to demonstrate.

import bpy
# Error: Not freed memory blocks: 1, total unfreed memory
def addOutputFileNode():

    name = "OutTest"
    ntree = bpy.context.scene.node_tree

    newNode = ntree.nodes.new(type='CompositorNodeOutputFile')
    newNode.name = name
    
    newNode.file_slots.remove(newNode.inputs[0])
    newNode.file_slots.new("New Image File Name")
    return newNode

if __name__ == "__main__":
    bpy.context.window.workspace = bpy.data.workspaces['Compositing']
    bpy.data.scenes["Scene"].use_nodes = True
    addOutputFileNode()

The likely bug here is that you’re allowed to remove the input socket in the first place.

The file output node socket allocates an image format which isn’t freed by the generic clear/remove idprop collection api. Doing so leaks the format each time you remove a socket.

So the socket must instead be removed using the operator call:

bpy.ops.node.output_file_remove_active_socket()
1 Like

Thanks for the heads up.