fanliang11 / surging

Surging is a micro-service engine that provides a lightweight, high-performance, modular RPC request pipeline. support Event-based Asynchronous Pattern and reactive programming ,The service engine supports http, TCP, WS,Grpc, Thrift,Mqtt, UDP, and DNS protocols. It uses ZooKeeper and Consul as a registry, and integrates it. Hash, random, polling, Fair Polling as a load balancing algorithm, built-in service governance to ensure reliable RPC communication, the engine contains Diagnostic, link tracking for protocol and middleware calls, and integration SkyWalking Distributed APM
MIT License
3.24k stars 923 forks source link

使用serviceProxyProvider.Invoke调用接口内存持续增长 #419

Open Penguin1990 opened 2 years ago

Penguin1990 commented 2 years ago

大佬,使用serviceProxyProvider.Invoke调用接口,压测一段时间内存一直增长,内存泄露现象好像还存在,辛苦指点下,谢谢 #413

fanliang11 commented 2 years ago

413 发现byte[] 长度为65560 一直占用增长未被释放,个人认为是netty 的ByteBuf未被释放,但是TransportMessageChannelHandlerAdapter里已经加了 ReferenceCountUtil.Release(buffer); 都手动释放了。

Penguin1990 commented 2 years ago

大佬,将代码 await Task.Run(() => { MessageListener.OnReceived(sender, message); }); 调整为 await MessageListener.OnReceived(sender, message);
好像可以解决问题,不知是否合适?

fanliang11 commented 2 years ago

首先netty 是通过EventLoop 串行执行,必然要通过Task.Run异步执行,要不然会阻塞,刚刚看了代码在ChannelRead 已经加了Task.Run,你可以试试按照以上方式修复下。

pastespider commented 11 months ago

字面意思应该不是这个问题,简单描述我的理解,就是使用了异步(其他线程执行),有些资源跨线程了,导致没有被合理的释放! 没看代码,有代码的不凡测测!