Skip to content

Commit 2dc3a3c

Browse files
fix: potential small memory leak in ConncectionApprovedMessage (#3486)
This resolves an issue where a very small memory leak could occur within the `ConnectionApprovedMessage`. ## Changelog - Fixed: Issue where there was a potential for a small memory leak in the `ConnectionApprovedMessage`. ## Testing and Documentation - No tests have been added. - No documentation changes or additions were necessary. <!-- Uncomment and mark items off with a * if this PR deprecates any API: ### Deprecated API - [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter yyyy-mm-dd)` entry. - [ ] An [api updater] was added. - [ ] Deprecation of the API is explained in the CHANGELOG. - [ ] The users can understand why this API was removed and what they should use instead. --> ## Backport No backport is needed as this fix is specific to v2.x. <!-- If this is a backport: - Add the following to the PR title: "\[Backport\] ..." . - Link to the original PR. If this needs a backport - state this here If a backport is not needed please provide the reason why. If the "Backports" section is not present it will lead to a CI test failure. -->
1 parent a3e41f5 commit 2dc3a3c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ Additional documentation and release notes are available at [Multiplayer Documen
1212

1313
### Fixed
1414

15+
- Fixed: Issue where there was a potential for a small memory leak in the `ConnectionApprovedMessage`. (#3486)
16+
1517
### Changed
1618

1719
## [2.4.0] - 2025-06-02

com.unity.netcode.gameobjects/Runtime/Messaging/Messages/ConnectionApprovedMessage.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ public void Handle(ref NetworkContext context)
262262
{
263263
NetworkLog.LogWarning($"[Client-{OwnerClientId}] Receiving duplicate connection approved. Client is already connected!");
264264
}
265+
ConnectedClientIds.Dispose();
265266
return;
266267
}
267268

@@ -304,6 +305,9 @@ public void Handle(ref NetworkContext context)
304305
}
305306
}
306307

308+
// Dispose after it has been used.
309+
ConnectedClientIds.Dispose();
310+
307311
// Only if scene management is disabled do we handle NetworkObject synchronization at this point
308312
if (!networkManager.NetworkConfig.EnableSceneManagement)
309313
{
@@ -387,7 +391,6 @@ public void Handle(ref NetworkContext context)
387391
}
388392
}
389393
}
390-
ConnectedClientIds.Dispose();
391394
}
392395
}
393396
}

0 commit comments

Comments
 (0)