Skip to content

ResourceLoader::LoadToken leaks #102476

@ialex32x

Description

@ialex32x

Tested versions

4.3-stable

System information

Windows 11

Issue description

Calling ResourceLoader.load_threaded_request without ResourceLoader.load_threaded_get causes leaks of ResourceLoader::LoadToken.

extends Node2D

const path := "res://icon.svg"
var finished := false

func _ready() -> void:
    var err := ResourceLoader.load_threaded_request(path, "", true, ResourceLoader.CACHE_MODE_IGNORE)
    print("load_threaded_request: %s" % error_string(err))


func _process(delta: float) -> void:
    if (finished):
        return
        
    var status = ResourceLoader.load_threaded_get_status(path)
    if (status != ResourceLoader.THREAD_LOAD_IN_PROGRESS):
        finished = true
        # without the following line, a ResourceLoader.LoadToken will be leaked
        # ResourceLoader.load_threaded_get(path)
        print("loaded")

I don't know whether it's expected behavior or not?

Steps to reproduce

Run the project scene from godot editor executable with parameters:
--verbose --path "PATH_TO_PROJECT/resource_loader_test" res://node_2d.tscn

ObjectDB::cleanup() will report a leaked instance which is a ResourceLoader::LoadToken.

Minimal reproduction project (MRP)

resource_loader_test.zip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    Status

    For team assessment

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions