Skip to content
This repository was archived by the owner on Jan 18, 2022. It is now read-only.

Commit 0ca21dd

Browse files
authored
Fix command response key leak (#1205)
* Fix leaking keys for command response callbacks * changelog
1 parent 4bc6b07 commit 0ca21dd

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
### Fixed
2020

2121
- Fixed a bug where the Deployment Launcher window would accept tags with 33 characters. [#1202](https://github.com/spatialos/gdk-for-unity/pull/1202)
22+
- Fixed a small memory leak with command response callbacks using MonoBehaviours. [#1205](https://github.com/spatialos/gdk-for-unity/pull/1205)
2223

2324
### Internal
2425

workers/unity/Packages/io.improbable.gdk.core/Subscriptions/Systems/CommandCallbackSystem.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public ulong RegisterCommandRequestCallback<T>(EntityId entityId, Action<T> call
3535
return callbacksRegistered++;
3636
}
3737

38-
public ulong RegisterCommandResponseCallback<T>(long requestId, Action<T> callback)
38+
public void RegisterCommandResponseCallback<T>(long requestId, Action<T> callback)
3939
where T : struct, IReceivedCommandResponse
4040
{
4141
if (!callbackManagers.TryGetManager(typeof(T), out var manager))
@@ -44,9 +44,7 @@ public ulong RegisterCommandResponseCallback<T>(long requestId, Action<T> callba
4444
callbackManagers.AddCallbackManager(typeof(T), manager);
4545
}
4646

47-
var key = ((CommandResponseCallbackManager<T>) manager).RegisterCallback(requestId, callback);
48-
keyToInternalKeyAndManager.Add(callbacksRegistered, (key, manager));
49-
return callbacksRegistered++;
47+
((CommandResponseCallbackManager<T>) manager).RegisterCallback(requestId, callback);
5048
}
5149

5250
public bool UnregisterCommandRequestCallback(ulong callbackKey)

0 commit comments

Comments
 (0)