Federico-Ciuffardi / GodotTouchInputManager

Asset that improves touch input support (includes new gestures) in the Godot game engine. It also translates mouse input to touch input.
MIT License
526 stars 35 forks source link

Memory Leaks at RawGesture.gd and Util.gd #27

Closed Sam2much96 closed 1 year ago

Sam2much96 commented 1 year ago

Error Log: WARNING: ObjectDB instances leaked at exit (run with --verbose for details). at: cleanup (core/object.cpp:2070) Leaked instance: GDScript:6674 - Resource path: Leaked instance: GDScript:6675 - Resource path: Leaked instance: GDScriptNativeClass:769 Leaked instance: GDScript:6672 - Resource path: res://addons/GDTIM-Demo-v2_1_2/RawGesture.gd Leaked instance: GDScript:6676 - Resource path: Leaked instance: GDScript:6673 - Resource path: res://addons/GDTIM-Demo-v2_1_2/Util.gd Leaked instance: GDScriptNativeClass:753 Hint: Leaked instances typically happen when nodes are removed from the scene tree (with remove_child()) but not freed (with free() or queue_free()). ERROR: Resources still in use at exit (run with --verbose for details). at: clear (core/resource.cpp:417) Resource still in use: res://addons/GDTIM-Demo-v2_1_2/Util.gd (GDScript) Resource still in use: res://addons/GDTIM-Demo-v2_1_2/RawGesture.gd (GDScript) Orphan StringName: drags Orphan StringName: copy Orphan StringName: latest_time Orphan StringName: Reference Orphan StringName: as_text Orphan StringName: new Orphan StringName: GDScriptNativeClass Orphan StringName: callv Orphan StringName: releases Orphan StringName: duplicate Orphan StringName: latest_event_id Orphan StringName: i_es Orphan StringName: relative Orphan StringName: get_script Orphan StringName: now Orphan StringName: index Orphan StringName: f Orphan StringName: back Orphan StringName: _update_screen_drag Orphan StringName: get Orphan StringName: start_time Orphan StringName: Util Orphan StringName: value Orphan StringName: Touch Orphan StringName: is_consistent Orphan StringName: speed Orphan StringName: get_ticks_usec Orphan StringName: es Orphan StringName: active_touches Orphan StringName: res://addons/GDTIM-Demo-v2_1_2/RawGesture.gd Orphan StringName: time Orphan StringName: rollback_absolute Orphan StringName: append Orphan StringName: pop_back Orphan StringName: res://addons/GDTIM-Demo-v2_1_2/Util.gd Orphan StringName: keys Orphan StringName: erase Orphan StringName: property_name Orphan StringName: elapsed_time Orphan StringName: events_name Orphan StringName: has Orphan StringName: pressed Orphan StringName: presses Orphan StringName: InputEventScreenTouch Orphan StringName: position Orphan StringName: length Orphan StringName: history Orphan StringName: Drag Orphan StringName: _add_history Orphan StringName: diff_limit Orphan StringName: Event Orphan StringName: event Orphan StringName: empty Orphan StringName: InputEventScreenDrag Orphan StringName: InputEventAction Orphan StringName: type Orphan StringName: get_ends Orphan StringName: _init Orphan StringName: size Orphan StringName: map_callv Orphan StringName: centroid Orphan StringName: GDScript Orphan StringName: _update_screen_touch Orphan StringName: rollback_relative Orphan StringName: SEC_IN_USEC Orphan StringName: vargs Orphan StringName: length_limit Orphan StringName: get_linear_event_history Orphan StringName: values StringName: 69 unclaimed string names at exit. Error: Process completed with exit code 1.

Sam2much96 commented 1 year ago

Reasons:

  1. RawGesture.gd introduces memory leaks once freed. Calling map_callv() in Util also introduces a memory leak in Util.gd
Federico-Ciuffardi commented 1 year ago

Hello @Sam2much96 thanks for reporting. Looks like this is a known Godot bug, which has been fixed in Godot 4.

Did you notice any performance issues due to this error or did you notice it because of the error message?

I managed to make the error message go away by deleting all RawGesture references in the type hints of RawGesture.gd, but I don't think it's worth doing this if the leak doesn't cause performance issues as the code is less clear without the type hints.

Sam2much96 commented 1 year ago

No, there was no performance issues. I'll implement this fix. Including the RawGesture reference as a type is good code, I only noticed the errors because my project is large and I compile using CI in Dockers. It might be an error only specific to CI compiler runs.