Skip to content

fix: Removed unnecessary GC Allocation #3527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: develop-2.0.0
Choose a base branch
from

Conversation

samlucas-unity
Copy link
Contributor

@samlucas-unity samlucas-unity commented Jun 27, 2025

Fix for MTTB-85 removed the use of a foreach causing an unnecessary GC Allocation.

Did a full sweep of internal NetworkManager.ConnectedClientsIds and replaced with either for loop or directly referencing the NetworkConnectionManager.ConnectedClientIds.

Changelog

  • Fixed: Removed unnecessary internal GC Allocations when using the IReadOnlyList NetworkManager.ConnectedClientsIds within a foreach statement by either replacing with a for loop or directly referencing the NetworkConnectionManager.ConnectedClientIds.

Testing and Documentation

  • Tested manually before and after fix to confirm the allocation was present and then absent.

Backport

Requires partial back port to v1.x.

@michalChrobot
Copy link
Collaborator

Do you know if this is only 2.X specific or should also be backported to 1.X (develop branch)?

Doing a full pass on the internal usage of NetworkManager.ConnectedClientsIds and replacing with NetworkConnectionManager.ConnectedClientIds to remove any other potential small memory allocations.
The best savings will be where it is used in universal RPCs.
@NoelStephensUnity
Copy link
Collaborator

Do you know if this is only 2.X specific or should also be backported to 1.X (develop branch)?

Portions of this PR could be back ported to v1.x.

@NoelStephensUnity NoelStephensUnity added the port:1.x-needed This issue needs to be ported to 1.X branch label Jul 11, 2025
@NoelStephensUnity NoelStephensUnity marked this pull request as draft July 11, 2025 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port:1.x-needed This issue needs to be ported to 1.X branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants