GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Adaptive allocator direct memory allocation regression · Issue #15850 · netty/netty

Adaptive allocator direct memory allocation regression #15850

New issue
Copy link
New issue
Copy link
Open
Open
Adaptive allocator direct memory allocation regression#15850
Copy link

Description

@onebeastchris
onebeastchris
opened on Nov 13, 2025
Issue body actions

Hello! 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!

Activity

  1. onebeastchris
    changed the title [-]Adaptive allocator direct memory memory allocation regression[/-] [+]Adaptive allocator direct memory allocation regression[/+] on Nov 13, 2025
  2. chrisvest commented on Nov 14, 2025

    @chrisvest
    chrisvest
    on Nov 14, 2025
    Member
    More actions

    If you can grab a flight recording with allocator events, I'd be interested in analyzing it.
    See https://github.com/netty/netty/wiki/Analyzing-Memory-Allocator-Behavior

    Reacted by chris
  3. onebeastchris commented on Nov 23, 2025

    @onebeastchris
    onebeastchris
    on Nov 23, 2025
    Author
    More actions

    Thanks for the response! I've asked someone who's affected, here's what they shared:

    https://www.mediafire.com/file/fr9cw7slorexwkh/netty-allocator.jfr/file

  4. chrisvest commented on Dec 9, 2025

    @chrisvest
    chrisvest
    on Dec 9, 2025
    Member
    More actions

    The mediafire website is not loading for me. You can try attaching the file directly to this issue, or try a google drive maybe?

  5. onebeastchris commented on Dec 14, 2025

    @onebeastchris
    onebeastchris
    on Dec 14, 2025
    Author
    More actions

    https://drive.google.com/file/d/1FJb29FWCmtSeJT9BGSop6ZkTYKhE6gaI/view?usp=drivesdk

    Here it is :)

    Reacted by Chris Vest
  6. chrisvest commented on Dec 16, 2025

    @chrisvest
    chrisvest
    on Dec 16, 2025
    Member
    More actions

    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
  7. laosijikaichele commented on Dec 17, 2025

    @laosijikaichele
    laosijikaichele
    on Dec 17, 2025
    Contributor
    More actions

    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:

    netty/buffer/src/main/java/io/netty/buffer/AdaptivePoolingAllocator.java

    Lines 143 to 162 in 5fe1eea

    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,
    };

  8. laosijikaichele commented on Dec 17, 2025

    @laosijikaichele
    laosijikaichele
    on Dec 17, 2025
    Contributor
    More actions

    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:

    Image

    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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.