Skip to content

RenderingServer.create_local_rendering_device() memory leaks #71003

@VanessB

Description

@VanessB

Godot version

v4.0.beta10.official

System information

Debian GNU/Linux 11 (bullseye), Intel Core i3-8130U CPU, Mesa Intel UHD Graphics 620 (KBL GT2)

Issue description

Memory leaks occur while using RenderingServer.create_local_rendering_device(). Moreover, the engine crashes after creating many local rendering devices (even if this is done in a scoped environment, see below). If rendering_device.free() is called, the following warning appears: drivers/vulkan/rendering_device_vulkan.cpp:8957 - 1 RID of type "<...>" was leaked., where <...> is any object, created with local rendering device (Shader, Texture, ...).

Steps to reproduce

The following code reproduces the bug:

extends Node

func _ready() -> void:
    for step in range(199):  # 199 times are enogh to crash the engine on my system.
        create_lrd()
        print(step)

func create_lrd() -> void:
    var rd := RenderingServer.create_local_rendering_device()

    # If something is done with rd here, it remains in memory even upon
    # return from this function.

    #rd.free() # No memory leaks occur, but Vulkan warnings are printed.
    # this line also fixes crashes.

Minimal reproduction project

RDMemoryLeak.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions