Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GD-598: Fixing memory leaks on test execution #599

Merged
merged 3 commits into from
Nov 21, 2024
Merged

GD-598: Fixing memory leaks on test execution #599

merged 3 commits into from
Nov 21, 2024

Conversation

MikeSchulze
Copy link
Owner

@MikeSchulze MikeSchulze commented Nov 21, 2024

Why

Running tests via CMD line shows a lot of memory leaks at program exit.

What

  • fixed releasing of all singletons
  • func_assert has problems with lambdas when using inside timer.timeout.connect, converted lambda into function
  • Handling of stored asserts in the thread context results in inconsistency during cleanup
  • fixed cleanup on GdUnitCommandHandlerTest

Finally, I have reduced most of the memory leaks nodes, but there are still GDScriptFunctionState orphaned nodes that I can't solve because these are handled internally by Godot see 74449

Statistics: | 947 tests cases | 0 error | 0 failed | 1 flaky | 13 skipped | 0 orphans |

Executed test suites: (100/104), 4 skipped
Executed test cases: (934/947), 13 skipped
Total time:        3min 0s 409ms
Open Report at: file:///home/runner/work/gdUnit4/gdUnit4/reports/report_1/index.html
Exit code: 0
----------------------------------------------------------------
Cleanup singletons ["GdUnitThreadManager", "GdUnitDefaultValueDecoders", "GdUnitCommandHandler"]

	Unregister singleton 'GdUnitThreadManager'
	Free singleton instance 'GdUnitThreadManager:<Object#507678557642>'
	Successfully freed 'GdUnitThreadManager'

	Unregister singleton 'GdUnitDefaultValueDecoders'
	Free singleton instance 'GdUnitDefaultValueDecoders:<Object#509540832395>'
	Successfully freed 'GdUnitDefaultValueDecoders'

	Unregister singleton 'GdUnitCommandHandler'
	Free singleton instance 'GdUnitCommandHandler:<Object#3858659025580>'
	Successfully freed 'GdUnitCommandHandler'
----------------------------------------------------------------
Finallize .. done
Finallize ..
-Orphan nodes report-----------------------
Finallize .. done
XR: Clearing primary interface
XR: Removed interface "Native mobile"
XR: Removed interface "OpenXR"
WARNING: ObjectDB instances leaked at exit (run with --verbose for details).
     at: cleanup (core/object/object.cpp:2327)
Leaked instance: GDScriptFunctionState:9223373291404658414
Leaked instance: GDScriptFunctionState:92233732947[6010](https://github.com/MikeSchulze/gdUnit4/actions/runs/11956449331/job/33331231410?pr=599#step:4:6018)1646
Leaked instance: GDScriptFunctionState:9223373292545509197
Leaked instance: GDScriptFunctionState:9223373291673093970
Leaked instance: GDScriptFunctionState:9223373293719914330
Leaked instance: GDScriptFunctionState:9223373292881053539
Leaked instance: GDScriptFunctionState:9223373296521709422
Leaked instance: GDScriptFunctionState:9223378085393468557
Leaked instance: GDScriptFunctionState:9223382060754801221
Leaked instance: GDScriptFunctionState:9223373293753472331
Leaked instance: GDScriptFunctionState:9223377142497156399
Leaked instance: GDScriptFunctionState:9223378085359924447
Leaked instance: GDScriptFunctionState:9223382060788375283
Hint: Leaked instances typically happen when nodes are removed from the scene tree (with `remove_child()`) but not freed (with `free()` or `queue_free()`).
Orphan StringName: test_case1 (static: 0, total: 1)
Orphan StringName: _validate_callback (static: 0, total: 1)
Orphan StringName: await_millis (static: 0, total: 5)
Orphan StringName: test_timeout_single_yield_wait (static: 0, total: 1)
Orphan StringName: test_timeout_2s (static: 0, total: 1)
Orphan StringName: _execute (static: 0, total: 1)
Orphan StringName: test_timeout_4s (static: 0, total: 1)
Orphan StringName: timeout (static: 2, total: 8)
Orphan StringName: cb_is_equal (static: 0, total: 2)
Orphan StringName: test_timeout_long_running_test_abort (static: 0, total: 1)
Orphan StringName: test_timeout_and_assert_fails (static: 0, total: 1)
StringName: 11 unclaimed string names at exit.
Run tests ends with 0

# Why
Running tests via CMD line shows a lot of memory leaks at program exit.

# What
- fixed releasing of all singletons
- `func_assert` has problems with lambdas when using inside `timer.timeout.connect`, converted lambda into function
- Handling of stored asserts in the thread context results in inconsistency during cleanup
@MikeSchulze MikeSchulze self-assigned this Nov 21, 2024
@MikeSchulze MikeSchulze linked an issue Nov 21, 2024 that may be closed by this pull request
@MikeSchulze MikeSchulze marked this pull request as ready for review November 21, 2024 15:19
@MikeSchulze MikeSchulze merged commit 5a745d4 into master Nov 21, 2024
@MikeSchulze MikeSchulze deleted the GD-598 branch November 21, 2024 15:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GD-598: Memory leaks at cmd tool exit
1 participant