From 8ac91f813f364ed3e8b4b6be1b0770124af0d1b0 Mon Sep 17 00:00:00 2001 From: SysError99 Date: Tue, 29 Aug 2023 03:12:53 +0700 Subject: [PATCH] [3.x] Fix JavaScript callback memory leak --- .../javascript/js/libs/library_godot_javascript_singleton.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/platform/javascript/js/libs/library_godot_javascript_singleton.js b/platform/javascript/js/libs/library_godot_javascript_singleton.js index ec58ce48e6e0..e6ebef0262fc 100644 --- a/platform/javascript/js/libs/library_godot_javascript_singleton.js +++ b/platform/javascript/js/libs/library_godot_javascript_singleton.js @@ -205,7 +205,9 @@ const GodotJSWrapper = { return; } const args = Array.from(arguments); - func(p_ref, GodotJSWrapper.get_proxied(args), args.length); + const argsProxy = new GodotJSWrapper.MyProxy(args); + func(p_ref, argsProxy.get_id(), args.length); + argsProxy.unref(); }; id = GodotJSWrapper.get_proxied(cb); return id;