GeezerVison is showing github.com — AdaptiveByteBufAllocator may be memory leak · Issue #14269 · netty/netty
AdaptiveByteBufAllocator may be memory leak #14269DescriptionExpected 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())//
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)
OS version (e.g. uname -a)
My colleague will provide some evidence later Activitynormanmaurer commented on Aug 29, 2024 Can you provide a heapdump ? linking12 commented on Aug 29, 2024 franz1981 commented on Aug 29, 2024 @linking12 something is off here:

what kind of cpu it is? it is a supported standard OpenJDK? franz1981 commented on Aug 29, 2024 linking12 commented on Aug 29, 2024
@linking12 something is off here:

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)
franz1981 commented on Aug 29, 2024 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... linking12 commented on Aug 29, 2024
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 franz1981 commented on Aug 29, 2024 @linking12 and now something "funny" which both me and @nitsanw are painfully much aware

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 linking12 commented on Aug 29, 2024
@linking12 and now something "funny" which both me and @nitsanw are painfully much aware

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? franz1981 commented on Aug 29, 2024 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. linking12 commented on Aug 29, 2024
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 normanmaurer commented on Aug 29, 2024 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. franz1981 commented on Aug 29, 2024 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 ;) linking12 commented on Aug 30, 2024
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
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|