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 — AdaptiveByteBufAllocator may be memory leak · Issue #14269 · netty/netty

AdaptiveByteBufAllocator may be memory leak #14269

New issue
Copy link
New issue
Copy link
Closed
Closed
AdaptiveByteBufAllocator may be memory leak#14269
Copy link
Assignees
franz1981
Labels
not a bug

Description

@linking12
linking12
opened on Aug 29, 2024
Issue body actions

Expected behavior

use AdaptiveByteBufAllocator do not OOM

Actual behavior

AdaptiveByteBufAllocator oom

Steps to reproduce

use LittleProxy

Server:

ServerBootstrap serverBootstrap = new ServerBootstrap()//
            .group(serverGroup.getProxyBoss(), serverGroup.getProxyWorker())//
            .childOption(ChannelOption.SO_LINGER, -1)//
            .childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE)//
            .childOption(ChannelOption.TCP_NODELAY, Boolean.TRUE)//
            .childOption(ChannelOption.SO_REUSEADDR, Boolean.TRUE)//
            .childOption(ChannelOption.SO_SNDBUF, 4 * 1024 * 1024)//
            .childOption(ChannelOption.SO_RCVBUF, 64 * 1024)//
            /**
             * @see https://github.com/netty/netty/pull/13075
             */
            .childOption(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator())//
            .option(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator())//

client:
       Bootstrap cb = new Bootstrap().group(eventLoopGroup)//
           .channel(proxyServer.getServerGroup().getSocketChannelClass())
           .option(ChannelOption.CONNECT_TIMEOUT_MILLIS, proxyServer.getConnectTimeout())//
           .option(ChannelOption.SO_KEEPALIVE, Boolean.TRUE)//
           .option(ChannelOption.TCP_NODELAY, Boolean.TRUE)//
           .option(ChannelOption.SO_REUSEADDR, Boolean.TRUE)//
           .option(ChannelOption.SO_SNDBUF, 4 * 1024 * 1024)//
           .option(ChannelOption.SO_RCVBUF, 64 * 1024)//
           .option(ChannelOption.WRITE_BUFFER_WATER_MARK, new WriteBufferWaterMark(8 * 1024, 32 * 1024))
           .option(ChannelOption.AUTO_READ, true)//
           /**
            * @see https://github.com/netty/netty/pull/13075
            */
           .option(ChannelOption.ALLOCATOR, new AdaptiveByteBufAllocator())//
           .handler(new ChannelInitializer<Channel>() {
               public void initChannel(Channel ch) throws Exception {
                   initChannelPipeline(ch.pipeline());
               }
           });
   

LittleProxy will OOM kill
when i delete AdaptiveByteBufAllocator is ok

Minimal yet complete reproducer code (or URL to code)

hard to provide

Netty version

<netty.version>4.1.112.Final</netty.version>
<netty-tcnative-boringssl-static.version>2.0.66.Final</netty-tcnative-boringssl-static.version>

JVM version (e.g. java -version)

jdk17

OS version (e.g. uname -a)

TBD

My colleague will provide some evidence later

Activity

  1. normanmaurer commented on Aug 29, 2024

    @normanmaurer
    normanmaurer
    on Aug 29, 2024
    Member
    More actions

    Can you provide a heapdump ?

  2. linking12 commented on Aug 29, 2024

    @linking12
    linking12
    on Aug 29, 2024
    Author
    More actions

    Can you provide a heapdump ?

    15m
    1

    20m
    2

    3h
    3

    heapdump

    https://drive.google.com/file/d/1IcYQvrFk3OJWsnf3j6jffP9ofB66fwOK/view?usp=drive_link

    @normanmaurer actually i do not find any heap excepiton in heapdump, i think is this is Off-heap memory leak
    Notice: all of this is not oom evidence, last night we have oom but do not keep evidence, so i restart application and keep 15m,20m, 3h evidence, also i have another node do not use (AdaptiveByteBufAllocator), everything is fine

  3. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    @linking12 something is off here:

    image

    what kind of cpu it is? it is a supported standard OpenJDK?

  4. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    image

    This is the problem: the number of allocators are just too much...you should use a single instance you store and configure somewhere OR just https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/ByteBufAllocator.java#L24 but providing -D-Dio.netty.allocator.type=adaptive

    instead, you're likely creating one allocator per connection

  5. linking12 commented on Aug 29, 2024

    @linking12
    linking12
    on Aug 29, 2024
    Author
    More actions

    @linking12 something is off here:

    image

    what kind of cpu it is? it is a supported standard OpenJDK?

    Architecture:        x86_64
    CPU op-mode(s):      32-bit, 64-bit
    Byte Order:          Little Endian
    CPU(s):              4
    On-line CPU(s) list: 0-3
    Thread(s) per core:  2
    Core(s) per socket:  2
    Socket(s):           1
    NUMA node(s):        1
    Vendor ID:           GenuineIntel
    CPU family:          6
    Model:               106
    Model name:          Intel(R) Xeon(R) Platinum 8375C CPU @ 2.90GHz
    Stepping:            6
    CPU MHz:             3444.097
    BogoMIPS:            5799.90
    Hypervisor vendor:   KVM
    Virtualization type: full
    L1d cache:           48K
    L1i cache:           32K
    L2 cache:            1280K
    L3 cache:            55296K
    NUMA node0 CPU(s):   0-3
    Flags:               fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx16 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch invpcid_single ssbd ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves wbnoinvd ida arat avx512vbmi pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq rdpid md_clear flush_l1d arch_capabilities
    
    openjdk version "17.0.10" 2024-01-16 LTS
    OpenJDK Runtime Environment Corretto-17.0.10.8.1 (build 17.0.10+8-LTS)
    OpenJDK 64-Bit Server VM Corretto-17.0.10.8.1 (build 17.0.10+8-LTS, mixed mode, sharing)
    
  6. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    Please read the comment at #14269 (comment)

    Regardless; the dump is not collected on the same machine I can tell, because the arch on the heap dump is ARM, while the cpu you past is an Intel Xeon.

    I can close this as soon as you fix the code as suggested...

  7. franz1981
    self-assigned this
    on Aug 29, 2024
  8. franz1981
    added
    not a bug
    on Aug 29, 2024
  9. linking12 commented on Aug 29, 2024

    @linking12
    linking12
    on Aug 29, 2024
    Author
    More actions

    Please read the comment at #14269 (comment)

    Regardless; the dump is not collected on the same machine I can tell, because the arch on the heap dump is ARM, while the cpu you past is an Intel Xeon.

    I can close this as soon as you fix the code as suggested...

    My fault, is docker container, is ARM
    @franz1981 thanks, I'll fix the code and let you know if there's any result.

    Reacted by Francesco Nigro
  10. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    @linking12 and now something "funny" which both me and @nitsanw are painfully much aware

    image

    your application is supposed to "just" use the adaptive allocator, but..as you can see there's some other parts of your application/libraries which don't think the same - causing, likely - to have more than one off-heap allocator instance in your application, (much) increased RSS, increased heap usage (because of the many thread local data structures that such allocators try hard to use to ensure good performance, etc etc).
    And this is likely happen even if you use the default allocator.
    This is usually dependent by shading (I see some alibaba shaded deps there), but not only, as you can see at eclipse-vertx/vert.x#5262

    @normanmaurer @chrisvest this is something I believe you will be very interested in

  11. linking12 commented on Aug 29, 2024

    @linking12
    linking12
    on Aug 29, 2024
    Author
    More actions

    @linking12 and now something "funny" which both me and @nitsanw are painfully much aware

    image

    your application is supposed to "just" use the adaptive allocator, but..as you can see there's some other parts of your application/libraries which don't think the same - causing, likely - to have more than one off-heap allocator instance in your application, (much) increased RSS, increased heap usage (because of the many thread local data structures that such allocators try hard to use to ensure good performance, etc etc). And this is likely happen even if you use the default allocator. This is usually dependent by shading (I see some alibaba shaded deps there), but not only, as you can see at eclipse-vertx/vert.x#5262

    @normanmaurer @chrisvest this is something I believe you will be very interested in

    @franz1981 i fixed code and make sure AdaptiveByteBufAllocator is single;
    so far so good,there is no native memory increase, I will monitor tomorrow to make sure everything is fixed

    BTW, I don't quite understand your question about Alibaba arthas, do you mean Arthas can't recognize new Allocator & impact performance?

  12. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    I mean that you have arenas which belong to other pools, not just the adaptive one. It is something quite visible in the name of the classes, which belong to the non adaptive one.

    Reacted by linking12
  13. linking12 commented on Aug 29, 2024

    @linking12
    linking12
    on Aug 29, 2024
    Author
    More actions

    I mean that you have arenas which belong to other pools, not just the adaptive one. It is something quite visible in the name of the classes, which belong to the non adaptive one.

    yes, Alibaba arthas provide monitor by java agent, is a netty server embed in my application

  14. normanmaurer commented on Aug 29, 2024

    @normanmaurer
    normanmaurer
    on Aug 29, 2024
    Member
    More actions

    you will need to also change the allocator in this one if you want to only use the adaptive one. That said I am not sure if this is possible at all.

  15. franz1981 commented on Aug 29, 2024

    @franz1981
    franz1981
    on Aug 29, 2024
    Contributor
    More actions

    as @normanmaurer said...due to package renaming the risk is that it won't work to just use one...although it seems to me @linking12 you have both a netty pooled one AND the shaded one, in addition to the adaptive.

    Said that, is unrelated to this issue, so as soon as you're happy we can close it ;)

  16. linking12 commented on Aug 30, 2024

    @linking12
    linking12
    on Aug 30, 2024
    Author
    More actions

    as @normanmaurer said...due to package renaming the risk is that it won't work to just use one...although it seems to me @linking12 you have both a netty pooled one AND the shaded one, in addition to the adaptive.

    Said that, is unrelated to this issue, so as soon as you're happy we can close it ;)

    I understand what you mean. Upgrading the Netty version of Alibaba Arthas is a difficult task. However, Alibaba Arthas has shaded, so it will not affect the application itself? In this issue, I observed that the memory does not seem to increase today. I think it has been fixed. I will observe Alibaba Arthas again.

    Reacted by Francesco Nigro and Chris Vest
  17. linking12
    closed this as completedon Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @franz1981
    franz1981

Labels

not a bug

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.