You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create a "ping" functionality in a messaging client, which requires to continuously connect to a list of servers over a period of time. I noticed that the client crashes after a few minutes because of a heap overflow. After calling await group.ShutdownGracefullyAsync();, shouldn't the memory be freed again? Why does that not happen?
Server Code (default code from example)
classProgram{staticasyncTaskMain(string[]args){varbossGroup=newMultithreadEventLoopGroup(1);varworkerGroup=newMultithreadEventLoopGroup();try{varbootstrap=newServerBootstrap();bootstrap.Group(bossGroup,workerGroup).Channel<TcpServerSocketChannel>().ChildHandler(newActionChannelInitializer<IChannel>(channel =>{channel.Pipeline.AddLast(newStringEncoder(),newStringDecoder(),newTelnetServerHandler());}));varbootstrapChannel=awaitbootstrap.BindAsync(3000);Console.WriteLine("Server started on port 3000");awaitTask.Delay(-1);awaitbootstrapChannel.CloseAsync();}finally{Task.WaitAll(bossGroup.ShutdownGracefullyAsync(),workerGroup.ShutdownGracefullyAsync());}}}
usingSystem;usingSystem.Net;usingSystem.Threading.Tasks;usingDotNetty.Transport.Channels;publicclassTelnetServerHandler:SimpleChannelInboundHandler<string>{publicoverridevoidChannelActive(IChannelHandlerContextcontext){context.WriteAsync($"Welcome to {Dns.GetHostName()} !");context.WriteAndFlushAsync($"It is {DateTime.Now} now !");}protectedoverridevoidChannelRead0(IChannelHandlerContextcontext,stringmessage){context.CloseAsync();}publicoverridevoidChannelReadComplete(IChannelHandlerContextcontext){context.Flush();}publicoverridevoidExceptionCaught(IChannelHandlerContextcontext,Exceptionexception){Console.WriteLine($"{exception}");context.CloseAsync();}publicoverrideboolIsSharable=>true;}
This is the client code. It connects to the server 10 times and closes all of its connections. The memory (16mb) allocated however still remain unfreed after closing.
I'm trying to create a "ping" functionality in a messaging client, which requires to continuously connect to a list of servers over a period of time. I noticed that the client crashes after a few minutes because of a heap overflow. After calling
await group.ShutdownGracefullyAsync();
, shouldn't the memory be freed again? Why does that not happen?Server Code (default code from example)
This is the client code. It connects to the server 10 times and closes all of its connections. The memory (16mb) allocated however still remain unfreed after closing.
Screen.Recording.2023-09-05.at.15.15.16.1.mov
The text was updated successfully, but these errors were encountered: