Skip to main content

MessageReceivePool

A static class in Alta.NetworkTransport.Runtime, Alta.NetworkingTransport.

Thread-safe pool of 64 KB byte arrays for received network messages, so the receive path doesn't allocate a new buffer each time.

Fields​

MemberWhat it is
const int MaximumMessageSizeSize of every pooled buffer: 65535 bytes.
const int MaximumPoolSizeCap on pooled buffers (100). Buffers returned past it are dropped.
3 private and internal fields
MemberWhat it is
private static bool isMonitoringWhen true, the editor logs a warning on a full pool. Always false in this build.
private static readonly Logger LoggerNLog logger for this class.
private static readonly ConcurrentBag<byte[]> PoolThe ConcurrentBag holding free buffers.

Methods​

MemberWhat it is
static byte[] Get()Takes a buffer from the pool, or allocates a new 65535-byte array if it is empty.
static void Put(byte[] bytes)Returns a buffer to the pool unless it already holds more than 100. Callers include the server packet receivers.