Currently every packet that is received is copied to a new byte array. Doing this will cause a lot of memory fragmentation in the long run.
To resolve this issue we can use the following features:
ArrayPool\<byte>.Shared
Using the arraypool, arrays can temporarily be borrowed.
ReadOnlySpan\<byte>
Using read only spans, no copies of the packet buffer needs to be created. We can use this to convert to and from byte[] to int.
Currently every packet that is received is copied to a new byte array. Doing this will cause a lot of memory fragmentation in the long run.
To resolve this issue we can use the following features:
ArrayPool\<byte>.Shared
Using the arraypool, arrays can temporarily be borrowed. ReadOnlySpan\<byte>
Using read only spans, no copies of the packet buffer needs to be created. We can use this to convert to and from byte[] to int.