Skip to content

fix: Fix cyclic references memory leaks

Fabio Alessandrelli requested to merge fales/w4gd:fix/lifecycle into main

Lambdas "capture" increments the reference count for RefCounted objects.

This can lead to memory leaks by introducing a cyclic reference when connecting a RefCounted object signal to a "parent" RefCounted method.

By connecting a script method instead of the lambda, Godot is able to avoid that (likely using weakrefs internally).

It is unclear if this is a bug or expected behavior.

This MR also refactors the lifecycle of client requests promises to ensure that request objects survive long enough for the entire chain to complete.

Edited by Fabio Alessandrelli

Merge request reports

Loading