NetCoreServer
NetCoreServer copied to clipboard
Running on linux got the out of memory or core dump, running on windows everything is ok
I just follow the example Example: TCP chat server,my server running on linux,the memory usage grow very quickly,and the last I got the out of memory or core dump.
this is error message:
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.StartAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.ProcessAccept(System.Net.Sockets.SocketAsyncEventArgs)
at NetCoreServer.TcpServer.OnAsyncCompleted(System.Object, System.Net.Sockets.SocketAsyncEventArgs)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs)
at System.Net.Sockets.SocketAsyncEventArgs.OnCompletedInternal()
at System.Net.Sockets.SocketAsyncEventArgs.ExecutionCallback(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Net.Sockets.SocketAsyncEventArgs.FinishOperationAsyncSuccess(Int32, System.Net.Sockets.SocketFlags)
at System.Net.Sockets.SocketAsyncEventArgs.CompletionCallback(Int32, System.Net.Sockets.SocketFlags, System.Net.Sockets.SocketError)
at System.Net.Sockets.SocketAsyncEventArgs.AcceptCompletionCallback(IntPtr, Byte[], Int32, System.Net.Sockets.SocketError)
at System.Net.Sockets.SocketAsyncContext+AcceptOperation.InvokeCallback(Boolean)
at System.Net.Sockets.SocketAsyncContext+OperationQueue`1[[System.__Canon, System.Private.CoreLib, Version=6.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].ProcessAsyncOperation(System.__Canon)
at System.Net.Sockets.SocketAsyncContext+ReadOperation.System.Threading.IThreadPoolWorkItem.Execute()
at System.Net.Sockets.SocketAsyncContext.HandleEvents(SocketEvents)
at System.Net.Sockets.SocketAsyncEngine.System.Threading.IThreadPoolWorkItem.Execute()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
at System.Threading.PortableThreadPool+WorkerThread.WorkerThreadStart()
at System.Threading.Thread.StartCallback()
zsh: IOT instruction (core dumped) ./IotNetgateApp
How should I do to sloved this problem?
I have use your examples, the TcpEchoServer and the TcpEchoClient for test,this is the test screenshot:
on linux

on windows

obviously, running on the linux the memory usage is huge than running on the windows
This is a sign of a memory leak. The way Linux handles memory is different that Windows.
"Memory Management in Windows uses Tree data structure and Linux uses Linked List data structure. Windows uses Cluster demand Paging where the pages are bought only when they are needed but simultaneously. Linux uses Demand paging where the pages will not be swapped from disk to RAM until they are needed." - Riya Dhamaskar
What Linux distro are you running?
Maybe try this tool for more details about the leak and a clue to patch this leak. https://www.golinuxcloud.com/how-to-find-memory-leaks/
@kerojiang look at the output of your test - clearly the TcpEchoClient application can't connect to the server, probably because you have run out of available TCP ports. Are you reporting an issue when this specific connection error happens? If so, you should amend the issue description.
Note that in normal operation memory usage is low on linux. I just tested using Arch Linux and .NET core 7.