Azure配置依赖netty-buffer的PooledByteBufAllocator内存泄漏排查求助
内存泄漏排查:Netty PooledByteBufAllocator 在Azure AKS Kafka流应用中占用大量内存
应用背景
我们在Azure Kubernetes Service(AKS)中运行一个Kafka流应用,核心流程为:从Azure Event Hubs消费消息,执行业务逻辑后将处理结果写入另一个Event Hub。应用的配置存储在Azure App Configuration Service中,采用一次性读取所有配置并缓存到对象中按需复用的方式。
依赖信息
当前使用com.azure:azure-data-appconfiguration:jar:1.2.4连接Azure App Configuration,该依赖间接引入了io.netty:netty-buffer:jar:4.1.68.Final,完整依赖树如下:
+- com.azure:azure-data-appconfiguration:jar:1.2.4:compile | +- com.azure:azure-core:jar:1.22.0:compile | \- com.azure:azure-core-http-netty:jar:1.11.2:compile | +- io.netty:netty-buffer:jar:4.1.68.Final:compile
注:业务逻辑中使用Google开源的diff-match-patch类,实现将变更文件应用到基础文件以生成新文件的功能。
问题描述
应用运行过程中内存使用率持续攀升,抓取堆转储分析后发现io.netty.buffer.PooledByteBufAllocator对象占用大量内存空间,初步判断存在内存泄漏。堆快照显示该Allocator实例持有大量未释放的ByteBuf资源,内存占比远超正常水平。
已尝试的排查动作
我们曾怀疑是旧版本依赖的问题,将azure-data-appconfiguration升级至最新版本1.3.6,对应的Netty buffer依赖升级为io.netty:netty-buffer:jar:4.1.79.Final,但内存泄漏问题并未解决。新版本依赖树如下:
+- com.azure:azure-data-appconfiguration:jar:1.3.6:compile | +- com.azure:azure-core:jar:1.31.0:compile | \- com.azure:azure-core-http-netty:jar:1.12.4:compile | +- io.netty:netty-buffer:jar:4.1.79.Final:compile
需求支持
netty-buffer是否存在已知的内存泄漏问题?- 如何追踪这些
PooledByteBufAllocator对象的创建堆栈? - 请提供排查并修复该内存泄漏的最佳实践方案。
内容的提问来源于stack exchange,提问作者chandu ram
相关产品推荐
相关产品推荐

