Skip to content

Commit ae2fc30

Browse files
onebeastchrismd-5
authored andcommitted
SpigotMC#3828: Set allocator using Netty system property to apply pooled allocator default globally
1 parent 2bafb70 commit ae2fc30

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

proxy/src/main/java/net/md_5/bungee/BungeeCord.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,14 @@ public void start() throws Exception
262262
ResourceLeakDetector.setLevel( ResourceLeakDetector.Level.DISABLED ); // Eats performance
263263
}
264264

265+
// https://github.com/netty/netty/wiki/Netty-4.2-Migration-Guide
266+
// The adaptive allocator, the new default allocator since Netty 4.2, has some memory issues.
267+
// Setting it globally also ensures that any plugins would also use the pooled allocator.
268+
if ( System.getProperty( "io.netty.allocator.type" ) == null )
269+
{
270+
System.setProperty( "io.netty.allocator.type", "pooled" );
271+
}
272+
265273
eventLoops = PipelineUtils.newEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() );
266274

267275
File moduleDirectory = new File( "modules" );

proxy/src/main/java/net/md_5/bungee/netty/PipelineUtils.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package net.md_5.bungee.netty;
22

33
import com.google.common.base.Preconditions;
4-
import io.netty.buffer.PooledByteBufAllocator;
54
import io.netty.channel.Channel;
65
import io.netty.channel.ChannelException;
76
import io.netty.channel.ChannelOption;
@@ -219,9 +218,6 @@ public boolean accept(Channel ch)
219218
{
220219
// IP_TOS is not supported (Windows XP / Windows Server 2003)
221220
}
222-
// https://github.com/netty/netty/wiki/Netty-4.2-Migration-Guide
223-
// TODO: check for AdaptiveByteBufAllocator
224-
ch.config().setAllocator( PooledByteBufAllocator.DEFAULT );
225221
ch.config().setWriteBufferWaterMark( MARK );
226222

227223
ch.pipeline().addLast( FRAME_DECODER, new Varint21FrameDecoder() );

0 commit comments

Comments
 (0)