From dc659538d34393036a3a155d98aae6496bed3825 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Fri, 9 May 2025 20:19:29 +0100 Subject: [PATCH] Set netty allocator earlier and more globally --- proxy/src/main/java/com/velocitypowered/proxy/Velocity.java | 5 +++++ .../velocitypowered/proxy/network/ConnectionManager.java | 6 ------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java index 0ec8622d..a6fc850b 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/Velocity.java @@ -47,6 +47,11 @@ public class Velocity { System.setProperty("io.netty.native.workdir", System.getProperty("velocity.natives-tmpdir")); } + // Restore allocator used before Netty 4.2 due to oom issues with the adaptive allocator + if (System.getProperty("io.netty.allocator.type") == null) { + System.setProperty("io.netty.allocator.type", "pooled"); + } + // Disable the resource leak detector by default as it reduces performance. Allow the user to // override this if desired. if (!VelocityProperties.hasProperty("io.netty.leakDetection.level")) { 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 777cb39a..7b724f61 100644 --- a/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java +++ b/proxy/src/main/java/com/velocitypowered/proxy/network/ConnectionManager.java @@ -29,7 +29,6 @@ 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; @@ -117,11 +116,6 @@ 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;