From 1ad1f3b215a27bb0d05941b9d643eb7344737684 Mon Sep 17 00:00:00 2001 From: chris Date: Thu, 8 May 2025 12:30:55 +0200 Subject: [PATCH] Use pooled netty allocator instead of default adaptive allocator (#1570) --- .../velocitypowered/proxy/network/ConnectionManager.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java index 7b724f61..777cb39a 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java @@ -29,6 +29,7 @@ import com.velocitypowered.proxy.network.netty.SeparatePoolInetNameResolver; import com.velocitypowered.proxy.protocol.netty.GameSpyQueryHandler; import io.netty.bootstrap.Bootstrap; import io.netty.bootstrap.ServerBootstrap; +import io.netty.buffer.PooledByteBufAllocator; import io.netty.channel.Channel; import io.netty.channel.ChannelFuture; import io.netty.channel.ChannelFutureListener; @@ -116,6 +117,11 @@ public final class ConnectionManager { bootstrap.group(this.bossGroup, this.workerGroup); } + // Restore allocator used before Netty 4.2 due to oom issues with the adaptive allocator + if (System.getProperty("io.netty.allocator.type") == null) { + bootstrap.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT); + } + final int binds = server.getConfiguration().isEnableReusePort() ? ((MultithreadEventExecutorGroup) this.workerGroup).executorCount() : 1;