Description
Syncing 20 Transforms from server to clients creates constant GC.Alloc call on each client of 1.4kB in the NetworkingManager Update loop. After doing deep profiling on the builds I have narrowed it down the allocation to the HandleIncomingData(ulong clientId, string channelName, ArraySegment data, float receiveTime) funcition.
This allocation happens (with same allocation values) both using the provided NetworkedTransform component as well as with a custom messaging system where each moving behaviour sends its new position at a frequency of 20Hz (same frequency is applied to the NetworkedTransform component). Profiler attached images show the described behaviour.
Although the amount of allocation is small being called on every client 20 times (20 moving objects) 20 times in a second (position update frequency) results in frequent garbage collection calls. This GC calls are quite unnoticeable on Windows build but when executed on a mobile device (Android) result in frame freezes on a per second basis.
To Reproduce
To reproduce the behaviour simply place 20 objects which have a random movement script attached, and either attach a NetworkedTransform component on to it or send their updated position 20 times per second through a custom message implemented through the CustomMessagingManager class. Start a server and a client and check the profiler for GC allocation calls.
Screenshots
profiler gc spikes

Every red spike in the Memory window corresponds to the same GC.Alloc function call highlighted in the Hierarchy Overview. At the beginning of the timeline in the CPU usage windows there is also a little spike indicating a GC collection occurrence (green box highlight). This collection happen every 2/3 seconds on windows builds and nearly every second on a mobile build.
Environment (please complete the following information):
- OS: Windows 10
- Unity Version: 2019.1
- MLAPI Version: latest
- MLAPI Commit: latest
Networking configuration are setted to default and I am using the UNET transport. Also when using the custom messaging, messages are sent on a UnreliableSequenced channel.
I recently discovered the MLAPI library and have digged into its features. I really love it, especially the way it improves on all issues of UNET and its deficiencies (loving custom messages and client RPC multiplexing). I hope this is the right place where to highlight the problem I am facing.
I am available to provide any further required detail. Hope it is just me doing something wrong.
regards,
Francesco
Description
Syncing 20 Transforms from server to clients creates constant GC.Alloc call on each client of 1.4kB in the NetworkingManager Update loop. After doing deep profiling on the builds I have narrowed it down the allocation to the HandleIncomingData(ulong clientId, string channelName, ArraySegment data, float receiveTime) funcition.
This allocation happens (with same allocation values) both using the provided NetworkedTransform component as well as with a custom messaging system where each moving behaviour sends its new position at a frequency of 20Hz (same frequency is applied to the NetworkedTransform component). Profiler attached images show the described behaviour.
Although the amount of allocation is small being called on every client 20 times (20 moving objects) 20 times in a second (position update frequency) results in frequent garbage collection calls. This GC calls are quite unnoticeable on Windows build but when executed on a mobile device (Android) result in frame freezes on a per second basis.
To Reproduce
To reproduce the behaviour simply place 20 objects which have a random movement script attached, and either attach a NetworkedTransform component on to it or send their updated position 20 times per second through a custom message implemented through the CustomMessagingManager class. Start a server and a client and check the profiler for GC allocation calls.
Screenshots

profiler gc spikes
Every red spike in the Memory window corresponds to the same GC.Alloc function call highlighted in the Hierarchy Overview. At the beginning of the timeline in the CPU usage windows there is also a little spike indicating a GC collection occurrence (green box highlight). This collection happen every 2/3 seconds on windows builds and nearly every second on a mobile build.
Environment (please complete the following information):
Networking configuration are setted to default and I am using the UNET transport. Also when using the custom messaging, messages are sent on a UnreliableSequenced channel.
I recently discovered the MLAPI library and have digged into its features. I really love it, especially the way it improves on all issues of UNET and its deficiencies (loving custom messages and client RPC multiplexing). I hope this is the right place where to highlight the problem I am facing.
I am available to provide any further required detail. Hope it is just me doing something wrong.
regards,
Francesco