diff --git a/Robust.Shared/CVars.cs b/Robust.Shared/CVars.cs index a1fe24a52ab..15621488790 100644 --- a/Robust.Shared/CVars.cs +++ b/Robust.Shared/CVars.cs @@ -55,9 +55,10 @@ protected CVars() /// /// Size of the pool for Lidgren's array buffers to send messages. + /// Set to 0 to disable pooling. /// /// - /// Set really high because it's probably constant across a server how much is getting used. + /// Higher just means more potentially wasted space and slower pool retrieval. /// public static readonly CVarDef NetPoolSize = CVarDef.Create("net.pool_size", 512, CVar.CLIENT | CVar.SERVER); diff --git a/Robust.Shared/Network/NetManager.cs b/Robust.Shared/Network/NetManager.cs index 44b3796e36a..7f0ef8b2a9c 100644 --- a/Robust.Shared/Network/NetManager.cs +++ b/Robust.Shared/Network/NetManager.cs @@ -576,7 +576,16 @@ private NetPeerConfiguration _getBaseNetPeerConfig() // ping the client once per second. netConfig.PingInterval = 1f; - netConfig.RecycledCacheMaxCount = _config.GetCVar(CVars.NetPoolSize); + var poolSize = _config.GetCVar(CVars.NetPoolSize); + + if (poolSize <= 0) + { + netConfig.UseMessageRecycling = false; + } + else + { + netConfig.RecycledCacheMaxCount = Math.Min(poolSize, 8192); + } netConfig.SendBufferSize = _config.GetCVar(CVars.NetSendBufferSize); netConfig.ReceiveBufferSize = _config.GetCVar(CVars.NetReceiveBufferSize);