GeezerVison is showing github.com — Adaptive allocator direct memory allocation regression · Issue #15850 · netty/netty
Adaptive allocator direct memory allocation regression #15850DescriptionHello! We're seeing some regressions with direct memory usage leaking in the Geyser-Standalone program that is now present (with the adaptive allocator set as the default) which we weren't seeing with the pooled adapter default previously. Here's a stacktrace:
java.lang.OutOfMemoryError: Cannot reserve 8388608 bytes of direct buffer memory (allocated: 8583896927, limit: 8589934592)
at java.nio.Bits.reserveMemory(Bits.java:178) ~[?:?]
at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:111) ~[?:?]
at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:360) ~[?:?]
at io.netty.util.internal.CleanerJava9.allocate(CleanerJava9.java:86) ~[geyser.jar:?]
at io.netty.util.internal.PlatformDependent.allocateDirect(PlatformDependent.java:600) ~[geyser.jar:?]
at io.netty.buffer.UnpooledDirectByteBuf.allocateDirectBuffer(UnpooledDirectByteBuf.java:138) ~[geyser.jar:?]
at io.netty.buffer.UnpooledDirectByteBuf.<init>(UnpooledDirectByteBuf.java:81) ~[geyser.jar:?]
at io.netty.buffer.UnpooledUnsafeDirectByteBuf.<init>(UnpooledUnsafeDirectByteBuf.java:48) ~[geyser.jar:?]
at io.netty.buffer.UnsafeByteBufUtil.newUnsafeDirectByteBuf(UnsafeByteBufUtil.java:698) ~[geyser.jar:?]
at io.netty.buffer.AdaptiveByteBufAllocator$DirectChunkAllocator.allocate(AdaptiveByteBufAllocator.java:115) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator$HistogramChunkController.newChunkAllocation(AdaptivePoolingAllocator.java:786) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator$Magazine.allocate(AdaptivePoolingAllocator.java:983) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator$Magazine.tryAllocate(AdaptivePoolingAllocator.java:861) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator$MagazineGroup.allocate(AdaptivePoolingAllocator.java:414) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator.allocate(AdaptivePoolingAllocator.java:263) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator.reallocate(AdaptivePoolingAllocator.java:326) ~[geyser.jar:?]
at io.netty.buffer.AdaptivePoolingAllocator$AdaptiveByteBuf.capacity(AdaptivePoolingAllocator.java:1545) ~[geyser.jar:?]
at io.netty.buffer.AbstractByteBuf.ensureWritable0(AbstractByteBuf.java:305) ~[geyser.jar:?]
at io.netty.buffer.AbstractByteBuf.ensureWritable(AbstractByteBuf.java:280) ~[geyser.jar:?]
at org.cloudburstmc.protocol.common.util.Zlib.inflate(Zlib.java:58) ~[geyser.jar:?]
at org.cloudburstmc.protocol.bedrock.netty.codec.compression.ZlibCompression.decode(ZlibCompression.java:36) ~[geyser.jar:?]
at org.cloudburstmc.protocol.bedrock.netty.codec.compression.CompressionCodec.decode(CompressionCodec.java:74) ~[geyser.jar:?]
at org.cloudburstmc.protocol.bedrock.netty.codec.compression.CompressionCodec.decode(CompressionCodec.java:12) ~[geyser.jar:?]
at io.netty.handler.codec.MessageToMessageCodec$1.decode(MessageToMessageCodec.java:67) ~[geyser.jar:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:91) ~[geyser.jar:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:120) ~[geyser.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:354) ~[geyser.jar:?]
at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:107) ~[geyser.jar:?]
at io.netty.handler.codec.MessageToMessageCodec.channelRead(MessageToMessageCodec.java:120) ~[geyser.jar:?]
at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:354) ~[geyser.jar:?]
at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1429) ~[geyser.jar:?]
at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:918) ~[geyser.jar:?]
at org.cloudburstmc.netty.channel.raknet.RakChannelPipeline.lambda$onUnhandledInboundMessage$0(RakChannelPipeline.java:60) ~[geyser.jar:?]
at io.netty.util.concurrent.AbstractEventExecutor.runTask(AbstractEventExecutor.java:148) ~[geyser.jar:?]
at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:141) ~[geyser.jar:?]
at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:535) ~[geyser.jar:?]
at io.netty.channel.SingleThreadIoEventLoop.run(SingleThreadIoEventLoop.java:201) ~[geyser.jar:?]
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:1193) ~[geyser.jar:?]
at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74) ~[geyser.jar:?]
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) ~[geyser.jar:?]
at java.lang.Thread.run(Thread.java:1583) [?:?]
This happened running https://github.com/GeyserMC/Geyser/commits/36a5980, running also netty 4.2.7-Final.
Relevant code:
https://github.com/CloudburstMC/Protocol/blob/3.0/common/src/main/java/org/cloudburstmc/protocol/common/util/Zlib.java#L38-L123
Another occurrence, albeit with another stacktrace (and geyser running as a plugin on the Velocity proxy software):
https://mclo.gs/Whb2yq8#L131 (https://github.com/PaperMC/Velocity/commits/a046f700, using netty 4.2.7-Final)
And here's another:
https://pastebin.com/V0rWrw2R (https://github.com/PaperMC/Velocity/commits/b6b6b20f, using netty 4.2.7-Final)
Unfortunately i don't have data on whether this is a recent regression as we (and other software) only recently re-enabled the adaptive allocator by default; see
PaperMC/Velocity@498a38c
GeyserMC/Geyser@6ad1105
I'm not too familiar with how these issues can be debugged (I'm not directly affected, but i can reach out to users who are to provide more data), would appreciate any tips - thank you in advance! Activitychanged the title [-]Adaptive allocator direct memory memory allocation regression[/-] [+]Adaptive allocator direct memory allocation regression[/+] on Nov 13, 2025chrisvest commented on Nov 14, 2025 onebeastchris commented on Nov 23, 2025 chrisvest commented on Dec 9, 2025 The mediafire website is not loading for me. You can try attaching the file directly to this issue, or try a google drive maybe? onebeastchris commented on Dec 14, 2025 chrisvest commented on Dec 16, 2025 Thanks, we'll take the profile into consideration as we work to improve the adaptive allocator.
Meanwhile, you can use the old pooled allocator by setting the io.netty.allocator.type=pooled system property, or configuring it directly in your code. Reacted by old driver and chris laosijikaichele commented on Dec 17, 2025 I checked the jfr-file, the sizes range from 1 byte to 1297688 bytes, we may need to add more and
fine grained size-classes to SIZE_CLASSES:
|
private static final int[] SIZE_CLASSES = { |
|
32, |
|
64, |
|
128, |
|
256, |
|
512, |
|
640, // 512 + 128 |
|
1024, |
|
1152, // 1024 + 128 |
|
2048, |
|
2304, // 2048 + 256 |
|
4096, |
|
4352, // 4096 + 256 |
|
8192, |
|
8704, // 8192 + 512 |
|
16384, |
|
16896, // 16384 + 512 |
|
32768, |
|
65536, |
|
}; |
laosijikaichele commented on Dec 17, 2025 Also, the average living buffers seems take different effects on allocators, the following shows the results of AllocationPatternSimulator based on 4.2-branch, which use 1024, 8192, 16384 as different average living buffers:
So, if the applications have different average living buffers, or the living buffers cumulatively increased to a threshold, then the memory consumption may have big difference.
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|