Skip to content

Leaks on exiting game on exported builds + Fix #75

@SimranZenov

Description

@SimranZenov

Below are the errors I get in the godot log when exiting game, which is directly related to TileMapDual.
[Godot 4.6, Compatibility renderer, Windows, Nvidia RTX 3050]

ERROR: 1 RID allocations of type 'N5GLES36ShaderE' were leaked at exit.
ERROR: 15 RID allocations of type 'N5GLES37TextureE' were leaked at exit.
ERROR: 5 RID allocations of type 'N5GLES313CanvasTextureE' were leaked at exit.
ERROR: Texture with GL ID of 201: leaked 652456 bytes.
at: ~Utilities (drivers/gles3/storage/utilities.cpp:77)
ERROR: Texture with GL ID of 241: leaked 983024 bytes.
at: ~Utilities (drivers/gles3/storage/utilities.cpp:77)
ERROR: Texture with GL ID of 242: leaked 393208 bytes.
at: ~Utilities (drivers/gles3/storage/utilities.cpp:77)
ERROR: Texture with GL ID of 243: leaked 393208 bytes.
at: ~Utilities (drivers/gles3/storage/utilities.cpp:77)
ERROR: Texture with GL ID of 244: leaked 98296 bytes.
at: ~Utilities (drivers/gles3/storage/utilities.cpp:77)
+more

Verbose:
Leaked instance: TileData:503232602116
Leaked instance: TileData:503249379333
Leaked instance: TileData:503266156550
Leaked instance: TileData:503282933767
Leaked instance: TileData:503299710984
Leaked instance: TileData:503316488201
Leaked instance: TileData:503333265418
Leaked instance: TileData:503350042635
Leaked instance: TileData:503366819852
Leaked instance: TileData:503383597069
Leaked instance: TileData:503400374286
Leaked instance: TileData:503417151503
Leaked instance: TileData:503433928720
Leaked instance: TileData:503450705937
Leaked instance: TileData:503467483154
Leaked instance: TileData:503484260371
Leaked instance: TileData:503501037588
Leaked instance: TileData:503517814805
Leaked instance: TileData:503534592022
Leaked instance: TileData:503551369239
Leaked instance: TileData:503568146456
(x how ever many tiles you may have)

Here is the fix that worked for me. Added to tile_map_dual.gd:

func _exit_tree() -> void:
	# Break TileSetWatcher ↔ TileSet reference chain to prevent resource leaks at shutdown.
	# TileSetWatcher (RefCounted) connects to TileSet.changed signal and holds tile_set ref,
	# creating a cycle that prevents garbage collection after all Nodes are freed.
	if _tileset_watcher:
		_tileset_watcher.check_tile_set(null)

I'm not 100% sure if this is the most appropriate way to fix this issue, but maybe someone could look into it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions