From bd78e726dc30705ed8d12f7f288bb78f970a783f Mon Sep 17 00:00:00 2001 From: Martijn Gerkes Date: Thu, 31 Oct 2019 11:01:56 +0000 Subject: [PATCH 1/3] Fix leaking keys for command response callbacks --- .../Subscriptions/Systems/CommandCallbackSystem.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/CommandCallbackSystem.cs b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/CommandCallbackSystem.cs index 143b4a8b8d..a2ef79e8f0 100644 --- a/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/CommandCallbackSystem.cs +++ b/workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/CommandCallbackSystem.cs @@ -35,7 +35,7 @@ public ulong RegisterCommandRequestCallback(EntityId entityId, Action call return callbacksRegistered++; } - public ulong RegisterCommandResponseCallback(long requestId, Action callback) + public void RegisterCommandResponseCallback(long requestId, Action callback) where T : struct, IReceivedCommandResponse { if (!callbackManagers.TryGetManager(typeof(T), out var manager)) @@ -44,9 +44,7 @@ public ulong RegisterCommandResponseCallback(long requestId, Action callba callbackManagers.AddCallbackManager(typeof(T), manager); } - var key = ((CommandResponseCallbackManager) manager).RegisterCallback(requestId, callback); - keyToInternalKeyAndManager.Add(callbacksRegistered, (key, manager)); - return callbacksRegistered++; + ((CommandResponseCallbackManager) manager).RegisterCallback(requestId, callback); } public bool UnregisterCommandRequestCallback(ulong callbackKey) From 86d0359e05e7d6513bb58ce5d365c96f8a1f2456 Mon Sep 17 00:00:00 2001 From: Martijn Gerkes Date: Thu, 31 Oct 2019 11:12:32 +0000 Subject: [PATCH 2/3] changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a509736d95..635a9b8427 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ ### Fixed - Fixed a bug where the Deployment Launcher window would accept tags with 33 characters. [#1202](https://github.com/spatialos/gdk-for-unity/pull/1202) +- Fixed small memory leak with command response callbacks using Monobehaviours. [#1205](https://github.com/spatialos/gdk-for-unity/pull/1205) ### Internal From 754c118ef50be9946f0799771117fceedaefcefc Mon Sep 17 00:00:00 2001 From: Martijn Gerkes Date: Thu, 31 Oct 2019 11:41:53 +0000 Subject: [PATCH 3/3] Update CHANGELOG.md Co-Authored-By: Paul Balaji --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 635a9b8427..9073ce111c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ ### Fixed - Fixed a bug where the Deployment Launcher window would accept tags with 33 characters. [#1202](https://github.com/spatialos/gdk-for-unity/pull/1202) -- Fixed small memory leak with command response callbacks using Monobehaviours. [#1205](https://github.com/spatialos/gdk-for-unity/pull/1205) +- Fixed a small memory leak with command response callbacks using MonoBehaviours. [#1205](https://github.com/spatialos/gdk-for-unity/pull/1205) ### Internal